diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-30 12:09:22 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-30 12:09:22 +0300 |
commit | ef144889c1bb80372e25f38fc89c7832ce84417a (patch) | |
tree | 54fa644c7be78fa1a562ca5f97b7f295647e1ce1 /spec/migrations | |
parent | 286bddcf3c62ca6fc499e1d5b6e678c0866fecc4 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/migrations')
-rw-r--r-- | spec/migrations/swap_issue_user_mentions_note_id_to_bigint_for_gitlab_dot_com_2_spec.rb | 5 | ||||
-rw-r--r-- | spec/migrations/swap_merge_request_user_mentions_note_id_to_bigint_2_spec.rb (renamed from spec/migrations/swap_merge_request_user_mentions_note_id_to_bigint_spec.rb) | 27 |
2 files changed, 31 insertions, 1 deletions
diff --git a/spec/migrations/swap_issue_user_mentions_note_id_to_bigint_for_gitlab_dot_com_2_spec.rb b/spec/migrations/swap_issue_user_mentions_note_id_to_bigint_for_gitlab_dot_com_2_spec.rb index 2c561730d95..1cb40d3708f 100644 --- a/spec/migrations/swap_issue_user_mentions_note_id_to_bigint_for_gitlab_dot_com_2_spec.rb +++ b/spec/migrations/swap_issue_user_mentions_note_id_to_bigint_for_gitlab_dot_com_2_spec.rb @@ -67,6 +67,11 @@ RSpec.describe SwapIssueUserMentionsNoteIdToBigintForGitlabDotCom2, feature_cate connection = described_class.new.connection connection.execute('ALTER TABLE issue_user_mentions ALTER COLUMN note_id TYPE bigint') connection.execute('ALTER TABLE issue_user_mentions ALTER COLUMN note_id_convert_to_bigint TYPE integer') + # Cleanup artefacts from executing `#down` in test setup + connection.execute('DROP INDEX IF EXISTS index_issue_user_mentions_on_note_id_convert_to_bigint') + connection.execute( + 'ALTER TABLE issue_user_mentions DROP CONSTRAINT IF EXISTS fk_issue_user_mentions_note_id_convert_to_bigint' + ) allow_any_instance_of(described_class).to receive(:com_or_dev_or_test_but_not_jh?).and_return(true) diff --git a/spec/migrations/swap_merge_request_user_mentions_note_id_to_bigint_spec.rb b/spec/migrations/swap_merge_request_user_mentions_note_id_to_bigint_2_spec.rb index 15b21d34714..bf08b666efe 100644 --- a/spec/migrations/swap_merge_request_user_mentions_note_id_to_bigint_spec.rb +++ b/spec/migrations/swap_merge_request_user_mentions_note_id_to_bigint_2_spec.rb @@ -3,7 +3,8 @@ require 'spec_helper' require_migration! -RSpec.describe SwapMergeRequestUserMentionsNoteIdToBigint, feature_category: :database do +# rubocop: disable RSpec/FilePath +RSpec.describe SwapMergeRequestUserMentionsNoteIdToBigint2, feature_category: :database do describe '#up' do before do # A we call `schema_migrate_down!` before each example, and for this migration @@ -61,6 +62,30 @@ RSpec.describe SwapMergeRequestUserMentionsNoteIdToBigint, feature_category: :da end end end + + it 'is a no-op if columns are already swapped' do + connection = described_class.new.connection + connection.execute('ALTER TABLE merge_request_user_mentions ALTER COLUMN note_id TYPE bigint') + connection.execute('ALTER TABLE merge_request_user_mentions ALTER COLUMN note_id_convert_to_bigint TYPE integer') + # Cleanup artefacts from executing `#down` in test setup + connection.execute('DROP INDEX IF EXISTS index_merge_request_user_mentions_note_id_convert_to_bigint') + connection.execute( + 'ALTER TABLE merge_request_user_mentions ' \ + 'DROP CONSTRAINT IF EXISTS fk_merge_request_user_mentions_note_id_convert_to_bigint' + ) + + allow_any_instance_of(described_class).to receive(:com_or_dev_or_test_but_not_jh?).and_return(true) + allow_any_instance_of(described_class).to receive(:columns_already_swapped?).and_return(true) + + migrate! + + user_mentions = table(:merge_request_user_mentions) + user_mentions.reset_column_information + + expect(user_mentions.columns.find { |c| c.name == 'note_id' }.sql_type).to eq('bigint') + expect(user_mentions.columns.find { |c| c.name == 'note_id_convert_to_bigint' }.sql_type).to eq('integer') + end # rubocop: enable RSpec/AnyInstanceOf end end +# rubocop: enable RSpec/FilePath |