diff options
author | charlieablett <cablett@gitlab.com> | 2019-07-16 14:25:12 +1200 |
---|---|---|
committer | charlieablett <cablett@gitlab.com> | 2019-07-25 23:00:01 +1200 |
commit | 9ff8a2e6f5069e750b7658d2938f9ac4be0eb8c5 (patch) | |
tree | 125f6ff8b20c57054bfb43aace7d53cbfb6c1e12 | |
parent | a1d693d8ae96247b1d32ef202c2d8eed61dd357d (diff) | |
download | gitlab-ce-4221-board-scope-shouldn-t-persist-1-when-one-selects-any-weight-or-any-milestone-ce.tar.gz |
Address reviewer comments4221-board-scope-shouldn-t-persist-1-when-one-selects-any-weight-or-any-milestone-ce
- DB migration back to non-background task
-rw-r--r-- | changelogs/unreleased/4221-board-scope-shouldn-t-persist-1-when-one-selects-any-weight-or-any-milestone.yml (renamed from changelogs/unreleased/4221-board-scope-shouldn-t-persist-1-when-one-selects-any-weight-or-any-milestone-ce.yml) | 0 | ||||
-rw-r--r-- | db/migrate/20190703001116_default_weight_to_nil.rb | 45 |
2 files changed, 10 insertions, 35 deletions
diff --git a/changelogs/unreleased/4221-board-scope-shouldn-t-persist-1-when-one-selects-any-weight-or-any-milestone-ce.yml b/changelogs/unreleased/4221-board-scope-shouldn-t-persist-1-when-one-selects-any-weight-or-any-milestone.yml index 54b47e19a2d..54b47e19a2d 100644 --- a/changelogs/unreleased/4221-board-scope-shouldn-t-persist-1-when-one-selects-any-weight-or-any-milestone-ce.yml +++ b/changelogs/unreleased/4221-board-scope-shouldn-t-persist-1-when-one-selects-any-weight-or-any-milestone.yml diff --git a/db/migrate/20190703001116_default_weight_to_nil.rb b/db/migrate/20190703001116_default_weight_to_nil.rb index 2c076ebdcc6..89e7f089468 100644 --- a/db/migrate/20190703001116_default_weight_to_nil.rb +++ b/db/migrate/20190703001116_default_weight_to_nil.rb @@ -1,49 +1,24 @@ # frozen_string_literal: true -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class DefaultWeightToNil < ActiveRecord::Migration[5.1] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. DOWNTIME = false - # When a migration requires downtime you **must** uncomment the following - # constant and define a short and easy to understand explanation as to why the - # migration requires downtime. - # DOWNTIME_REASON = '' - - # When using the methods "add_concurrent_index", "remove_concurrent_index" or - # "add_column_with_default" you must disable the use of transactions - # as these methods can not run in an existing transaction. - # When using "add_concurrent_index" or "remove_concurrent_index" methods make sure - # that either of them is the _only_ method called in the migration, - # any other changes should go in a separate migration. - # This ensures that upon failure _only_ the index creation or removing fails - # and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - # disable_ddl_transaction! - def up - update_board_weights_from_none_to_any + execute(update_board_weights_query) end def down - update_board_weights_from_any_to_none - end - - # up method - - def update_board_weights_from_none_to_any - execute("UPDATE boards SET weight = null WHERE weight = -1") + # no-op end - # down method + private - def update_board_weights_from_any_to_none - execute("UPDATE boards SET weight = -1 WHERE weight = null") + # Only 288 records to update, as of 2019/07/18 + def update_board_weights_query + <<~HEREDOC + UPDATE boards + SET weight = NULL + WHERE boards.weight = -1 + HEREDOC end end |