Reputation: 5892
Rather than having 20,000 migration files over the next 5 years, is there a better way to scale a Rails app? For example, I want to add a column to a Model without creating another migration file.
Can I, for example, create a new migration to add a column, migrate the changes, and then remove the migration file? Is there a better way to handle this as the application scales?
Upvotes: 2
Views: 855
Reputation:
As long as you keep the schema.rb
file, you are free to delete the old migration files. (But first make sure you have run the migrations before deleting them!)
You can use rake db:schema:dump
to create an up to date schema file.
Upvotes: 3
Reputation: 2364
Well, you can add the column manually in the mysql/pqsql/oracle client, and then edit the original migration file to add the column. Something like:
t.integer :new_column_level, null: false, default: 1
but then all the servers where the app is installed must be updated manually. One advantage of migration files is that capistrano will run the changes in the next deployment.
I also try to avoid new migration files and I do so, but that's because I know and handle all my servers.
Upvotes: 1