0

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.

Nurbo
  • 115
  • 6

1 Answers1

1

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
abo-elleef
  • 2,100
  • 1
  • 14
  • 16
  • Hi, Leef! Thanks! Can one change data, for example value of an entire column from null to 0, with db:seed? Or is it only for seeding? – Nurbo Apr 22 '13 at 17:49
  • in seed file you can write any code which can be written in rails console so you can do Model.find(id).update_attribute(:attr_name,0) – abo-elleef Apr 22 '13 at 21:44