[ACCEPTED]-Delete old migrations files in a Rails app-rails-migrations
You don't need to keep around your old migration 23 files in a Rails app, because your database 22 schema should be captured either in schema.rb 21 or an equivalent SQL file that can be used 20 to regenerate your schema.
Migrations are 19 not the authoritative source for your database 18 schema. That role falls to either db/schema.rb 17 or an SQL file which Active Record generates 16 by examining the database. They are not 15 designed to be edited, they just represent 14 the current state of the database.
There 13 is no need (and it is error prone) to deploy 12 a new instance of an app by replaying the 11 entire migration history. It is much simpler 10 and faster to just load into the database 9 a description of the current schema, which 8 is in schema.rb or the SQL file.
This file 7 should be versioned and kept in source control.
To 6 set up automatic schema.rb generation, modify 5 config/application.rb by the
config.active_record.schema_format setting, which 4 may be :ruby or :sql.
If :ruby is selected 3 then the schema is stored in db/schema.rb.
If 2 :sql is selected, the schema is dumped out 1 in native SQL format of
You can delete your old migrations. After 3 you have done this, when you are setting 2 up your app you will need to run:
Instead 1 of:
here is what I did, I found the last version 5 migrated on production
ActiveRecord::SchemaMigration.last.version and deleted all 4 the migrations before that in my source 3 code.
not the best way but I did
find db/migrate -type f, copied 2 the list of files before the last version 1 and
pbpaste | rm (macos).
More Related questions