Commit f4d7293c authored by Andreas Brandl's avatar Andreas Brandl

Remove with_lock_retries from RenameTableHelpers

Also update docs to suggest using lock-retries at the
migration level.
parent d1dc96a6
# frozen_string_literal: true
class RenameInstanceStatisticsMeasurements < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
class RenameInstanceStatisticsMeasurements < Gitlab::Database::Migration[1.0]
enable_lock_retries!
def up
rename_table_safely(:analytics_instance_statistics_measurements, :analytics_usage_trends_measurements)
......
# frozen_string_literal: true
class RenameServicesToIntegrations < ActiveRecord::Migration[6.1]
include Gitlab::Database::MigrationHelpers
class RenameServicesToIntegrations < Gitlab::Database::Migration[1.0]
include Gitlab::Database::SchemaHelpers
enable_lock_retries!
# Function and trigger names match those migrated in:
# - https://gitlab.com/gitlab-org/gitlab/-/merge_requests/49916
# - https://gitlab.com/gitlab-org/gitlab/-/merge_requests/51852
......
......@@ -60,6 +60,8 @@ Consider the next release as "Release N.M".
Execute a standard migration (not a post-migration):
```ruby
enable_lock_retries!
def up
rename_table_safely(:issues, :tickets)
end
......
......@@ -4,27 +4,27 @@ module Gitlab
module Database
module RenameTableHelpers
def rename_table_safely(old_table_name, new_table_name)
with_lock_retries do
transaction do
rename_table(old_table_name, new_table_name)
execute("CREATE VIEW #{old_table_name} AS SELECT * FROM #{new_table_name}")
end
end
def undo_rename_table_safely(old_table_name, new_table_name)
with_lock_retries do
transaction do
execute("DROP VIEW IF EXISTS #{old_table_name}")
rename_table(new_table_name, old_table_name)
end
end
def finalize_table_rename(old_table_name, new_table_name)
with_lock_retries do
transaction do
execute("DROP VIEW IF EXISTS #{old_table_name}")
end
end
def undo_finalize_table_rename(old_table_name, new_table_name)
with_lock_retries do
transaction do
execute("CREATE VIEW #{old_table_name} AS SELECT * FROM #{new_table_name}")
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment