2

I have a legacy Rails app that's in production for a few years. It started as Rails 5.2 app and has been recently upgraded to Rails6+.

ag ActiveRecord db/migrate | grep Migration
db/migrate/20181012164950_add_foos.rb:3: class AddFoos < ActiveRecord::Migration[5.2]
db/migrate/20201008043949_add_bars.rb:3: class AddBars < ActiveRecord::Migration[6.1]

I'm wondering what's the recommended way of handling db migrations generated in an older Rails version(notice ActiveRecord::Migration[5.2] parent class name) after you upgraded your Rails dependency?

Is it recommended to update those numbers(e.g. [5.2] to your latest version instead(to future proof it)? Is it safe at all?

Related questions:

What are the brackets [5.1] after ActiveRecord Migration and how does it work?

how to understand "ActiveRecord::Migration[5.2]" rails / ruby

BinaryButterfly
  • 18,137
  • 13
  • 50
  • 91
  • 2
    I'd delete them. Your `db/schema.rb` or `db/structure.sql` has everything already and the chances of successfully rolling back that far are pretty much zero. Old migrations are just in the way. – mu is too short May 28 '21 at 15:33

0 Answers0