Search code examples
ruby-on-railsrails-migrationsrails-postgresql

Rails: last migration reapplied


Sometimes rake db:migrate tries to run migrations which have already been successfully migrated (without any errors). When I check the schema_migrations table, the repetitive migration is not there.

I've noticed that this only happens when I use migrations to modify data in my db without changing the db schema (for ex. change all values of a column of a table).

My question is, what's the reason for this behavior? Is using migration to change data considered to be bad practice in Rails? What's the best way to just modify db data then?

I'm using rails 3.2.6 with postgresql.


Solution

  • i think migration files are for doing the DDL part

    • createing/drop table
    • add/remove columns
    • set default values

    but for almost 9 months with rails now i use seed.rb file in the db directory to seed data in the db you can run it as

        rake db:seed