Commit d18d5775 authored by Josianne Hyson's avatar Josianne Hyson

Update database migration docs to avoid rubocop

The suggested approach in this example would require the addition of a
rubocop disable flag. We can just use the helper method instead, as the
`with_lock_retries` functionality is built into it.

MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/45157
parent 25d6d461
......@@ -295,13 +295,16 @@ end
Adding foreign key to `projects`:
We can use the `add_concurrenct_foreign_key` method in this case, as this helper method
has the lock retries built into it.
```ruby
include Gitlab::Database::MigrationHelpers
disable_ddl_transaction!
def up
with_lock_retries do
add_foreign_key :imports, :projects, column: :project_id, on_delete: :cascade
end
add_concurrent_foreign_key :imports, :projects, column: :project_id, on_delete: :cascade
end
def down
......@@ -316,10 +319,10 @@ Adding foreign key to `users`:
```ruby
include Gitlab::Database::MigrationHelpers
disable_ddl_transaction!
def up
with_lock_retries do
add_foreign_key :imports, :users, column: :user_id, on_delete: :cascade
end
add_concurrent_foreign_key :imports, :users, column: :user_id, on_delete: :cascade
end
def down
......
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