diff options
author | Felipe Artur <felipefac@gmail.com> | 2018-03-05 11:39:24 -0300 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2018-03-05 14:30:56 -0300 |
commit | 9946d0813c8e377ecf22552c4af075e563144712 (patch) | |
tree | 0f1399f16d1d6c70e41d60e11d0fa8a85db913dc /db | |
parent | dd071c4b6e9754a0abeec45ab2040d9e2d5a62b8 (diff) | |
download | gitlab-ce-9946d0813c8e377ecf22552c4af075e563144712.tar.gz |
Address review comments
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20180227182112_add_group_id_to_boards.rb | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/db/migrate/20180227182112_add_group_id_to_boards.rb b/db/migrate/20180227182112_add_group_id_to_boards.rb index d5da85bebcd..8e5460d44c9 100644 --- a/db/migrate/20180227182112_add_group_id_to_boards.rb +++ b/db/migrate/20180227182112_add_group_id_to_boards.rb @@ -1,8 +1,3 @@ -# This is part of a backport from EE group boards feature which a few extra steps -# are required on this migration since it will be merged into EE which already -# contains the group_id column. -# like checking if the group_id column already exists before adding it. - class AddGroupIdToBoards < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers @@ -11,24 +6,24 @@ class AddGroupIdToBoards < ActiveRecord::Migration DOWNTIME = false def up - unless group_id_exists? - add_column :boards, :group_id, :integer - add_foreign_key :boards, :namespaces, column: :group_id, on_delete: :cascade - add_concurrent_index :boards, :group_id + return if group_id_exists? + + add_column :boards, :group_id, :integer + add_foreign_key :boards, :namespaces, column: :group_id, on_delete: :cascade + add_concurrent_index :boards, :group_id - change_column_null :boards, :project_id, true - end + change_column_null :boards, :project_id, true end def down - if group_id_exists? - remove_foreign_key :boards, column: :group_id - remove_index :boards, :group_id if index_exists? :boards, :group_id - remove_column :boards, :group_id - - execute "DELETE from boards WHERE project_id IS NULL" - change_column_null :boards, :project_id, false - end + return unless group_id_exists? + + remove_foreign_key :boards, column: :group_id + remove_index :boards, :group_id if index_exists? :boards, :group_id + remove_column :boards, :group_id + + execute "DELETE from boards WHERE project_id IS NULL" + change_column_null :boards, :project_id, false end private |