summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2016-08-30 21:24:10 +0000
committerStan Hu <stanhu@gmail.com>2016-08-30 21:24:10 +0000
commitca39763dbdf88668ba45f38074f3aa720c2ca8d9 (patch)
tree6ad9308cdb4313c2b3f0c24436fd65851d034f5d
parentdafbcf63bd4eb7a90b611b9054d7de7832e3c97a (diff)
parenta476e6f5e53c54bcc74a482f0695564713da7dd0 (diff)
downloadgitlab-ce-ca39763dbdf88668ba45f38074f3aa720c2ca8d9.tar.gz
Merge branch 'lock_fix' into 'master'
Remove default value for lock_version ## What does this MR do? From the very beginning we added `lock_version` column with default value, then we reverted that MR. A bit later we added that migration again but column's default value has been removed from migration. So if you installed GitLab form master it's possible that you have default value, which caused the bug. We don't need to change a CHANGELOG here I think. Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/21527 and https://dev.gitlab.org/gitlab/organization/issues/971 See merge request !6111
-rw-r--r--db/migrate/20160827011312_ensure_lock_version_has_no_default.rb16
-rw-r--r--db/schema.rb2
2 files changed, 17 insertions, 1 deletions
diff --git a/db/migrate/20160827011312_ensure_lock_version_has_no_default.rb b/db/migrate/20160827011312_ensure_lock_version_has_no_default.rb
new file mode 100644
index 00000000000..7c55bc23cf2
--- /dev/null
+++ b/db/migrate/20160827011312_ensure_lock_version_has_no_default.rb
@@ -0,0 +1,16 @@
+class EnsureLockVersionHasNoDefault < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ change_column_default :issues, :lock_version, nil
+ change_column_default :merge_requests, :lock_version, nil
+
+ execute('UPDATE issues SET lock_version = 1 WHERE lock_version = 0')
+ execute('UPDATE merge_requests SET lock_version = 1 WHERE lock_version = 0')
+ end
+
+ def down
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 227e10294e4..0cd8648da2e 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20160824103857) do
+ActiveRecord::Schema.define(version: 20160827011312) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"