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>2020-01-07 00:07:43 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-07 00:07:43 +0300
commit015663b70f1bcdae4483e38c2beac884f92da5b8 (patch)
tree6dd5a59c7f9a27c3cca22801ca30bf3dd8f9b401 /lib/gitlab/database
parent5eb11b697d7ee280b0b5c2ff9a1850a3b5e9b7e3 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/database')
-rw-r--r--lib/gitlab/database/migration_helpers.rb12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/gitlab/database/migration_helpers.rb b/lib/gitlab/database/migration_helpers.rb
index f9340b262e5..1f246620a9c 100644
--- a/lib/gitlab/database/migration_helpers.rb
+++ b/lib/gitlab/database/migration_helpers.rb
@@ -158,7 +158,7 @@ module Gitlab
# name - The name of the foreign key.
#
# rubocop:disable Gitlab/RailsLogger
- def add_concurrent_foreign_key(source, target, column:, on_delete: :cascade, name: nil)
+ def add_concurrent_foreign_key(source, target, column:, on_delete: :cascade, name: nil, validate: true)
# Transactions would result in ALTER TABLE locks being held for the
# duration of the transaction, defeating the purpose of this method.
if transaction_open?
@@ -197,10 +197,16 @@ module Gitlab
# Validate the existing constraint. This can potentially take a very
# long time to complete, but fortunately does not lock the source table
# while running.
+ # Disable this check by passing `validate: false` to the method call
+ # The check will be enforced for new data (inserts) coming in,
+ # but validating existing data is delayed.
#
# Note this is a no-op in case the constraint is VALID already
- disable_statement_timeout do
- execute("ALTER TABLE #{source} VALIDATE CONSTRAINT #{options[:name]};")
+
+ if validate
+ disable_statement_timeout do
+ execute("ALTER TABLE #{source} VALIDATE CONSTRAINT #{options[:name]};")
+ end
end
end
# rubocop:enable Gitlab/RailsLogger