Re:Rails SeedMigrations: Like schema migrations, but for you...
by nthj on Wednesday June 11, 2014 @11:21AM
(#7878459)
I currently just use regular Rails migrations for this. In fact, I've executed each of the examples you provided using database migrations. You mentioned not wanting to use the console or a one-off script, but why would I want to switch over to SeedMigrations from regular ActiveRecord migrations?
[ Parent
| on HN ]
Re:Rails SeedMigrations: Like schema migrations, but for you...
by dschwartz88 on Wednesday June 11, 2014 @11:28AM
(#7878496)
Another one of the engineers here. While using ActiveRecord migrations will work for production systems, when setting up development or test systems using rake db:schema:load will not actually insert those records. Since rake db:schema:load is simply loading the current schema from schema.rb, you will still have to add those records into seeds.
Re:Rails SeedMigrations: Like schema migrations, but for you...
by netghost on Wednesday June 11, 2014 @11:42AM
(#7878572)
As an alternative approach; we take a similar view to the grandparent, but run a full set of migrations instead of just copying the schema.
It actually works quite well. The tradeoff being that it may take a little longer, but we're typically talking tenths of a second.
Re:Rails SeedMigrations: Like schema migrations, but for you...
by sanderjd on Wednesday June 11, 2014 @01:39PM
(#7879275)
Ah, interesting, thanks for the explanation - I was wondering the same thing as your parent. I always do db:migrate instead of db:schema:load, but I can see the advantages of avoiding that (particularly if you have tons and tons of migrations).