Live data from Hacker News

Rails SeedMigrations: Like schema migrations, but for your data

engineering.harrys.com

11–12 of 12 posts

Re: Rails SeedMigrations: Like schema migrations, but for your data

#11
post #5

Earlier quoted context omitted.

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?

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.

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).

Re: Rails SeedMigrations: Like schema migrations, but for your data

#12

We used a db/seeds.rb file mainly for fake data to get our development environments going until there is real user data to work with. Can you use SeedMigrations to have a set of dev seeds vs prod seeds?

We didn't design the gem to handle "dev" data, the idea was really to handle "real" data, such as Product in our case. Though if you feel like there would be a use case for dev seeds, I would be happy to discuss that with you (either here/twitter/mail etc ...)
Post reply on HN