Avoid adding more than one foreign key within `with_lock_retries`
What does this MR do?
This MR improves the Migration/WithLockRetriesDisallowedMethod
to prevent the usages of more than one add_foreign_key
within with_lock_retries
and links to https://docs.gitlab.com/ee/development/migration_style_guide.html#examples.
Refs #260317 (comment 422644313)
Example
This is from the current CI
Offenses:
db/migrate/20200123090839_remove_analytics_repository_table_fks_on_projects.rb:20:7: C: Migration/WithLockRetriesDisallowedMethod: Avoid adding more than one foreign key with the with_lock_retries. See https://docs.gitlab.com/ee/development/migration_style_guide.html#examples
add_foreign_key :analytics_repository_files, :projects, on_delete: :cascade
^^^^^^^^^^^^^^^
db/migrate/20200123090839_remove_analytics_repository_table_fks_on_projects.rb:21:7: C: Migration/WithLockRetriesDisallowedMethod: Avoid adding more than one foreign key with the with_lock_retries. See https://docs.gitlab.com/ee/development/migration_style_guide.html#examples
add_foreign_key :analytics_repository_file_edits, :projects, on_delete: :cascade
^^^^^^^^^^^^^^^
db/migrate/20200123090839_remove_analytics_repository_table_fks_on_projects.rb:22:7: C: Migration/WithLockRetriesDisallowedMethod: Avoid adding more than one foreign key with the with_lock_retries. See https://docs.gitlab.com/ee/development/migration_style_guide.html#examples
add_foreign_key :analytics_repository_file_commits, :projects, on_delete: :cascade
^^^^^^^^^^^^^^^
db/migrate/20200123091422_remove_analytics_repository_files_fk_on_other_analytics_tables.rb:19:7: C: Migration/WithLockRetriesDisallowedMethod: Avoid adding more than one foreign key with the with_lock_retries. See https://docs.gitlab.com/ee/development/migration_style_guide.html#examples
add_foreign_key :analytics_repository_file_edits, :analytics_repository_files, on_delete: :cascade
^^^^^^^^^^^^^^^
db/migrate/20200123091422_remove_analytics_repository_files_fk_on_other_analytics_tables.rb:20:7: C: Migration/WithLockRetriesDisallowedMethod: Avoid adding more than one foreign key with the with_lock_retries. See https://docs.gitlab.com/ee/development/migration_style_guide.html#examples
add_foreign_key :analytics_repository_file_commits, :analytics_repository_files, on_delete: :cascade
^^^^^^^^^^^^^^^
Does this MR meet the acceptance criteria?
Conformity
- [-] Changelog entry
- [-] Documentation (if required)
-
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides - [-] Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. - [-] Tested in all supported browsers
- [-] Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
- [-] Label as security and @ mention
@gitlab-com/gl-security/appsec
- [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
- [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by Adam Hegyi