diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2017-11-24 14:27:38 +0100 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2017-11-24 14:28:41 +0100 |
commit | 4beacdb2ca6ea884473cb63aee603951df7f2da1 (patch) | |
tree | aff09b018c5f0937c790464bb380224c356f65dc /db/migrate/20171124125042_add_default_values_to_merge_request_states.rb | |
parent | 7c1e54d58d7ee0308b865d9563f1dfeb54568e16 (diff) | |
download | gitlab-ce-4beacdb2ca6ea884473cb63aee603951df7f2da1.tar.gz |
Fix defaults for MR states and merge statusesdefault-values-for-mr-states
This ensures that merge_requests.state and merge_requests.merge_status
both have a proper default value and NOT NULL constraint on database
level. We also make sure to update any bogus rows first, without blowing
up the database.
Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/40534
Diffstat (limited to 'db/migrate/20171124125042_add_default_values_to_merge_request_states.rb')
-rw-r--r-- | db/migrate/20171124125042_add_default_values_to_merge_request_states.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/db/migrate/20171124125042_add_default_values_to_merge_request_states.rb b/db/migrate/20171124125042_add_default_values_to_merge_request_states.rb new file mode 100644 index 00000000000..d08863c3b78 --- /dev/null +++ b/db/migrate/20171124125042_add_default_values_to_merge_request_states.rb @@ -0,0 +1,19 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddDefaultValuesToMergeRequestStates < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + def up + change_column_default :merge_requests, :state, :opened + change_column_default :merge_requests, :merge_status, :unchecked + end + + def down + change_column_default :merge_requests, :state, nil + change_column_default :merge_requests, :merge_status, nil + end +end |