diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-07-28 15:15:38 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-07-28 15:15:38 +0000 |
commit | 883be9c67bdb78bfb695e23cf0b76102d0a358fc (patch) | |
tree | ef8ce3487feed41984785d9238c91eeb1fe5f0ec /db | |
parent | 58c058c9607a887be74ecc4c5cdc5c0f755341da (diff) | |
parent | 6ef87a20832d1a2581cb85e60eda46f999c55a81 (diff) | |
download | gitlab-ce-883be9c67bdb78bfb695e23cf0b76102d0a358fc.tar.gz |
Merge branch 'merge-issuable-reopened-into-opened-state' into 'master'
Merge issuable "reopened" state into "opened"
See merge request !12972
Diffstat (limited to 'db')
-rw-r--r-- | db/post_migrate/20170719150301_merge_issuable_reopened_into_opened_state.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/db/post_migrate/20170719150301_merge_issuable_reopened_into_opened_state.rb b/db/post_migrate/20170719150301_merge_issuable_reopened_into_opened_state.rb new file mode 100644 index 00000000000..acc0fc7a0ac --- /dev/null +++ b/db/post_migrate/20170719150301_merge_issuable_reopened_into_opened_state.rb @@ -0,0 +1,32 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class MergeIssuableReopenedIntoOpenedState < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + class Issue < ActiveRecord::Base + self.table_name = 'issues' + + include EachBatch + end + + class MergeRequest < ActiveRecord::Base + self.table_name = 'merge_requests' + + include EachBatch + end + + def up + [Issue, MergeRequest].each do |model| + say "Changing #{model.table_name}.state from 'reopened' to 'opened'" + + model.where(state: 'reopened').each_batch do |batch| + batch.update_all(state: 'opened') + end + end + end +end |