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
path: root/spec
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2019-04-11 17:29:44 +0300
committerYorick Peterse <yorickpeterse@gmail.com>2019-06-17 18:06:20 +0300
commit0f777a8d49568d3f5ffdd4b75b594f07e9fbd2f0 (patch)
tree848ee08d3e8c7dde2a5308dfafc30df856196d34 /spec
parentcfcdfdd2de6009e7ce55e6a415825a0eca75f0c9 (diff)
Allow custom names for concurrent foreign keys
This is necessary for backporting the EE schema to ensure backported foreign keys use the same key names.
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/database/migration_helpers_spec.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/lib/gitlab/database/migration_helpers_spec.rb b/spec/lib/gitlab/database/migration_helpers_spec.rb
index 4e83b27e4a5..1e4c4c38f74 100644
--- a/spec/lib/gitlab/database/migration_helpers_spec.rb
+++ b/spec/lib/gitlab/database/migration_helpers_spec.rb
@@ -214,6 +214,23 @@ describe Gitlab::Database::MigrationHelpers do
model.add_concurrent_foreign_key(:projects, :users, column: :user_id)
end
+ it 'allows the use of a custom key name' do
+ expect(model).to receive(:add_foreign_key).with(
+ :projects,
+ :users,
+ column: :user_id,
+ on_delete: :cascade,
+ name: :foo
+ )
+
+ model.add_concurrent_foreign_key(
+ :projects,
+ :users,
+ column: :user_id,
+ name: :foo
+ )
+ end
+
it 'does not create a foreign key if it exists already' do
expect(model).to receive(:foreign_key_exists?).with(:projects, :users, column: :user_id).and_return(true)
expect(model).not_to receive(:add_foreign_key)
@@ -257,6 +274,16 @@ describe Gitlab::Database::MigrationHelpers do
model.add_concurrent_foreign_key(:projects, :users, column: :user_id)
end
+
+ it 'allows the use of a custom key name' do
+ expect(model).to receive(:disable_statement_timeout).and_call_original
+ expect(model).to receive(:execute).with(/statement_timeout/)
+ expect(model).to receive(:execute).ordered.with(/NOT VALID/)
+ expect(model).to receive(:execute).ordered.with(/VALIDATE CONSTRAINT.+foo/)
+ expect(model).to receive(:execute).with(/RESET ALL/)
+
+ model.add_concurrent_foreign_key(:projects, :users, column: :user_id, name: :foo)
+ end
end
end
end