Add linting for migration files in the future
Description of the proposal
Add linting for migration files in the future
- This can cause issues as seen in !142303 (comment 1781915037) and more fully explained in internal slack Where rails will start enumerating until that date hits. That makes it more likely to hit a merge conflict with other migrations.
- example/proof in this MRs pipelines https://gitlab.com/gitlab-org/gitlab/-/jobs/6219869304#L733
# Checks to ensure timestamp used for a migration file occurs in the past.
# If it is not in the past, this can cause Rails to enumerate the file names until that date has passed.
# For instance if the migration below exists:
# 30000220000000_some_migration.rb
# It will cause rails generator to create new migrations as an enumeration on that timestamp until 30000220 has
# passed. We would be generating files like this:
# 30000220000001_some_migration.rb
# 30000220000002_some_migration.rb
# That methodology increases the probability of collision with others contributing at the same time
# as each file is merely enumerated by 1.
#
# @example
# # bad - date is in the future
# 30000220000000_some_migration.rb
#
# # good - date is in the past
# 20240219000000_some_migration.rb
#
Check-list
-
Mention this proposal in the relevant Slack channels (e.g. #development
,#backend
,#frontend
) -
The MR doesn't have significant objections, and is getting a majority of 👍 vs👎 (remember that we don't need to reach a consensus) -
Follow the review process as usual
Edited by Doug Stull