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 ...@@ -295,13 +295,16 @@ end
Adding foreign key to `projects`: 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 ```ruby
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
disable_ddl_transaction!
def up def up
with_lock_retries do add_concurrent_foreign_key :imports, :projects, column: :project_id, on_delete: :cascade
add_foreign_key :imports, :projects, column: :project_id, on_delete: :cascade
end
end end
def down def down
...@@ -316,10 +319,10 @@ Adding foreign key to `users`: ...@@ -316,10 +319,10 @@ Adding foreign key to `users`:
```ruby ```ruby
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
disable_ddl_transaction!
def up def up
with_lock_retries do add_concurrent_foreign_key :imports, :users, column: :user_id, on_delete: :cascade
add_foreign_key :imports, :users, column: :user_id, on_delete: :cascade
end
end end
def down 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