Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-10-11 05:58:47 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-10-11 05:58:47 +0300
commit61b630468c6ad6c9bf06be8e9b02785c995f7a5a (patch)
tree0b770ff9ffa17fd5cf554695eb1381ce9187db4d /spec/migrations/20230726144458_swap_notes_id_to_bigint_for_self_managed_spec.rb
parent8b7cfdd3397edb18f0e0d4f1c71d6b9282f68aef (diff)
Add latest changes from gitlab-org/gitlab@16-4-stable-ee
Diffstat (limited to 'spec/migrations/20230726144458_swap_notes_id_to_bigint_for_self_managed_spec.rb')
-rw-r--r--spec/migrations/20230726144458_swap_notes_id_to_bigint_for_self_managed_spec.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/migrations/20230726144458_swap_notes_id_to_bigint_for_self_managed_spec.rb b/spec/migrations/20230726144458_swap_notes_id_to_bigint_for_self_managed_spec.rb
index b4552cebc58..96151de1148 100644
--- a/spec/migrations/20230726144458_swap_notes_id_to_bigint_for_self_managed_spec.rb
+++ b/spec/migrations/20230726144458_swap_notes_id_to_bigint_for_self_managed_spec.rb
@@ -115,6 +115,42 @@ RSpec.describe SwapNotesIdToBigintForSelfManaged, feature_category: :database do
end
end
end
+
+ context 'when having different naming for fk_d83a918cb1 foreign key' do
+ before do
+ connection.execute('ALTER TABLE system_note_metadata DROP CONSTRAINT IF EXISTS fk_d83a918cb1')
+ connection.execute('ALTER TABLE system_note_metadata DROP CONSTRAINT IF EXISTS fk_rails_d83a918cb1')
+ connection.execute('ALTER TABLE system_note_metadata ADD CONSTRAINT fk_rails_d83a918cb1 FOREIGN KEY (note_id)
+ REFERENCES notes(id) ON DELETE CASCADE')
+ end
+
+ after do
+ connection.execute('ALTER TABLE system_note_metadata DROP CONSTRAINT IF EXISTS fk_rails_d83a918cb1')
+ connection.execute('ALTER TABLE system_note_metadata DROP CONSTRAINT IF EXISTS fk_d83a918cb1_tmp')
+ connection.execute('ALTER TABLE system_note_metadata ADD CONSTRAINT fk_d83a918cb1 FOREIGN KEY (note_id)
+ REFERENCES notes(id) ON DELETE CASCADE')
+ end
+
+ it 'swaps the columns' do
+ disable_migrations_output do
+ reversible_migration do |migration|
+ migration.before -> {
+ notes_table.reset_column_information
+
+ expect(notes_table.columns.find { |c| c.name == 'id' }.sql_type).to eq('integer')
+ expect(notes_table.columns.find { |c| c.name == 'id_convert_to_bigint' }.sql_type).to eq('bigint')
+ }
+
+ migration.after -> {
+ notes_table.reset_column_information
+
+ expect(notes_table.columns.find { |c| c.name == 'id' }.sql_type).to eq('bigint')
+ expect(notes_table.columns.find { |c| c.name == 'id_convert_to_bigint' }.sql_type).to eq('integer')
+ }
+ end
+ end
+ end
+ end
end
end
end