Using Migrations to load user data?

30 views
Skip to first unread message

bob.n...@gmail.com

unread,
Nov 13, 2014, 1:44:11 PM11/13/14
to rubyonra...@googlegroups.com
@rails Hi,

I'm new to rails, and my dev team wants to load all user content data (not reference data or admin users) via migrations. Is this going to be problematic?

If so, how can I convince them that is a likely mistake? What would be the alternatives?

Thanks,

Bob

Colin Law

unread,
Nov 13, 2014, 4:29:31 PM11/13/14
to rubyonra...@googlegroups.com
Use rake db:seed, which runs db/seeds.rb. That is what it is for.

Colin

>
> Thanks,
>
> Bob
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/5a065c67-52ca-4852-9c72-c77023f6009c%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

bob.n...@gmail.com

unread,
Nov 14, 2014, 9:18:13 AM11/14/14
to rubyonra...@googlegroups.com
Hi Colin,

Thanks for your response. I totally agree with you. Do you or anyone else have experience with these kind of data content migrations going bad?  Basically, the only argument I can provide the team is that it "smells" bad, the intent of migrations seem to be for data structure, not content (other than reference data or an initial admin user), and all migration documentation/examples only show DDL type statements.

Thanks.

Jason Fleetwood-Boldt

unread,
Nov 14, 2014, 10:04:36 AM11/14/14
to rubyonra...@googlegroups.com
re: Data migrations

There's a gem for that! (I happen to be its author)



By separating your schema migrations from data migrations, you can separate the concerns easily. (And, for example, not run your data migrations in a test or QA environment if you so choose)

Also schema migrations necessarily mean you have to restart your app (downtime), and data-only migrations can be run while the app is running. 

Almost every production-scale website with traffic I've worked on has needed data migrations at some point. While making everything a data migration is costly to developers, doing it for batch imports makes perfect sense. Let's say your company acquired another company, and you wanted to import the other company's data. Yes, you could reasonably use a rake task, but data migrations make it easy to keep track of and ensure that all environments get the same treatment.

Although I understand the sentiment that it "smells bad" (and indeed, running a large data job in a schema migration can take a while, leaving your site down during the migration), the purpose of my gem is to address a real business need in a way that isn't so smelly to developers. In the context of this discussion, I'd call it a middle-ground approach.

-Jason


On Nov 14, 2014, at 9:18 AM, bob.n...@gmail.com wrote:

Hi Colin,

Thanks for your response. I totally agree with you. Do you or anyone else have experience with these kind of data content migrations going bad?  Basically, the only argument I can provide the team is that it "smells" bad, the intent of migrations seem to be for data structure, not content (other than reference data or an initial admin user), and all migration documentation/examples only show DDL type statements.

Thanks.

----

Jason Fleetwood-Boldt

All material © Jason Fleetwood-Boldt 2014. Public conversations may be turned into blog posts (original poster information will be made anonymous). Email ja...@datatravels.com with questions/concerns about this.

Reply all
Reply to author
Forward
0 new messages