Skip to content

Add linting for migration files in the future

Doug Stull requested to merge ensure-migration-is-in-future into master

Description of the proposal

Add linting for migration files in the future

      # 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

Merge request reports