Rails SeedMigrations: Like schema migrations, but for your data
engineering.harrys.com
Rails SeedMigrations: Like schema migrations, but for your data
1–10 of 12 posts
Re: Rails SeedMigrations: Like schema migrations, but for your data
#2Re: Rails SeedMigrations: Like schema migrations, but for your data
#3Re: Rails SeedMigrations: Like schema migrations, but for your data
#4Re: Rails SeedMigrations: Like schema migrations, but for your data
#5Hey, one of the engineers who built this over here, happy to answer any questions you have.
Re: Rails SeedMigrations: Like schema migrations, but for your data
#6Hey, one of the engineers who built this over here, happy to answer any questions you have.
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?
Re: Rails SeedMigrations: Like schema migrations, but for your data
#7This is so useful, thanks! Can it get existing data from the database? Or does it only translate the seeds.rb file? I've been using https://github.com/rroblak/seed_dump in the past.
Re: Rails SeedMigrations: Like schema migrations, but for your data
#8What is the difference between this and say the seed-fu gem? Is having historical data the main advantage, so you can do rollbacks and such?
- Having the seeds.rb file mirror the records you need from production. You wouldn't want to to register your User model, since you don't want all your production users. You would want to register a model like Product.
- Being able to easily migrate data on our production systems. Being able to easily migrate (and rollback if something goes wrong) is key to having predictable deploys (for us at least).
Re: Rails SeedMigrations: Like schema migrations, but for your data
#9Earlier 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.
It actually works quite well. The tradeoff being that it may take a little longer, but we're typically talking tenths of a second.