Ensure BacthedMigration and BatchedJob always have pause_ms attribute
What does this MR do?
Define pause_ms
attribute for both BatchedMigration
and BatchedJob
models to make sure older migrations will execute even if the column is not created in the DB yet.
Thanks to ActiveRecord's Attributes API, if the database column is missing then pause_ms
is a virtual attribute, if the column exists, then pause_ms
is fetched from/ saved to the database. This way we do not have to do check like responds_to?
or has_attribute?
everywhere we want to use the attribute.
See #328816 (closed).
I did not find a good way to write tests for this, and did not want to mess with dropping columns inside specs, so tested the following variants manually (by calling BatchedMigration#create_batched_job!
in console).
Migration | ||||
---|---|---|---|---|
20210413155324_add_pause_seconds_to_batched_background_migrations.rb | Up | Up | Down | Down |
20210414045322_add_pause_seconds_to_batched_background_migration_jobs.rb | Up | Down | Down | Up |
Result |
Screenshots (strongly suggested)
Does this MR meet the acceptance criteria?
Conformity
-
📋 Does this MR need a changelog?-
I have included a changelog entry. -
I have not included a changelog entry because this is a developer facing change.
-
-
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
Related to #328816 (closed)