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-19 15:57:54 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-10-19 15:57:54 +0300
commit419c53ec62de6e97a517abd5fdd4cbde3a942a34 (patch)
tree1f43a548b46bca8a5fb8fe0c31cef1883d49c5b6 /lib/gitlab/database/migration_helpers.rb
parent1da20d9135b3ad9e75e65b028bffc921aaf8deb7 (diff)
Add latest changes from gitlab-org/gitlab@16-5-stable-eev16.5.0-rc42
Diffstat (limited to 'lib/gitlab/database/migration_helpers.rb')
-rw-r--r--lib/gitlab/database/migration_helpers.rb19
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/gitlab/database/migration_helpers.rb b/lib/gitlab/database/migration_helpers.rb
index 60cec12b4b5..efcceafda90 100644
--- a/lib/gitlab/database/migration_helpers.rb
+++ b/lib/gitlab/database/migration_helpers.rb
@@ -567,8 +567,8 @@ module Gitlab
# table - The table containing the column.
# column - The name of the column to change.
# new_type - The new column type.
- def cleanup_concurrent_column_type_change(table, column)
- temp_column = "#{column}_for_type_change"
+ def cleanup_concurrent_column_type_change(table, column, temp_column: nil)
+ temp_column ||= "#{column}_for_type_change"
transaction do
# This has to be performed in a transaction as otherwise we might have
@@ -586,10 +586,10 @@ module Gitlab
# type_cast_function - Required if the conversion back to the original type is not automatic
# batch_column_name - option for tables without a primary key, in this case
# another unique integer column can be used. Example: :user_id
- def undo_cleanup_concurrent_column_type_change(table, column, old_type, type_cast_function: nil, batch_column_name: :id, limit: nil)
+ def undo_cleanup_concurrent_column_type_change(table, column, old_type, type_cast_function: nil, batch_column_name: :id, limit: nil, temp_column: nil)
Gitlab::Database::QueryAnalyzers::RestrictAllowedSchemas.require_ddl_mode!
- temp_column = "#{column}_for_type_change"
+ temp_column ||= "#{column}_for_type_change"
# Using a descriptive name that includes orinal column's name risks
# taking us above the 63 character limit, so we use a hash
@@ -751,7 +751,7 @@ module Gitlab
trigger_name = rename_trigger_name(table, columns, temporary_columns)
remove_rename_triggers(table, trigger_name)
- temporary_columns.each { |column| remove_column(table, column) }
+ temporary_columns.each { |column| remove_column(table, column, if_exists: true) }
end
alias_method :cleanup_conversion_of_integer_to_bigint, :revert_initialize_conversion_of_integer_to_bigint
@@ -909,6 +909,11 @@ module Gitlab
name = index.name.gsub(old, new)
+ if name.length > 63
+ digest = Digest::SHA256.hexdigest(name).first(10)
+ name = "idx_copy_#{digest}"
+ end
+
options = {
unique: index.unique,
name: name,
@@ -1204,6 +1209,10 @@ into similar problems in the future (e.g. when new tables are created).
end
end
+ def lock_tables(*tables, mode: :access_exclusive)
+ execute("LOCK TABLE #{tables.join(', ')} IN #{mode.to_s.upcase.tr('_', ' ')} MODE")
+ end
+
private
def multiple_columns(columns, separator: ', ')