Reputation: 52367
I am now thinking about adding db/migrate
folder into .gitignore
file.
Since migrations could be somehow mixed/messed up, it is often recommended to lean on schema.rb
when starting to work on ongoing project rather then run migrations one by one.
Is it a good idea to exclude migrations files from repo and rely on rake db:setup
?
Upvotes: 0
Views: 412
Reputation: 4116
I would highly recommend that you commit all your migration files, from db/migrate along with your schema.rb
This answer will be helpful: What is the right approach to deal with Rails db/schema.rb file in GIT?
Along with: http://ryanbigg.com/2010/12/commit-it-or-else/
Upvotes: 2
Reputation: 13181
You could if you are single developer or if you rely on db:setup
and db:seed
for all members of your team.
But if you plan to deploy your application to a production server you really should not, because migration are here to update the schema accordingly with the actual schema version of the targeted machine. With them, just the rights changes are applied. Without them, relying only on schema.rb
would force a complete reset of the database, emptying it. And that's not what we want most on the time on production servers.
Also migration are a useful reference for your database status while coding, they help to find quickly the list of fields of each models, in a more readable way than schema.rb
.
If you did never deploy you app to a production server and if you are single developer (or if other developers agree) you can refactor your migration by integrating all changes (add_field
...) in the original create_table
migration
Upvotes: 3