简体   繁体   中英

Rails Migrations or Manual Database creation?

I'm a newbie to Rails and just started writing my first application in Rails.

Now, i have a question on which i need some advice. Should i go ahead with Rails Migrations for generating the database tables or should i stick to the old MySQL way of creating each table manually.

What's your say?? What way proves to be a better choice eventually?

I might be the only one different with a differing opinion here, but I usually have a pretty darn good idea of what my structure is going to look like. So I usually start with a fairly complete schema.rb file. I can then load the schema ( rake db:schema:load ) to set up my database structure. My migrations then track modifications from that original schema.

A good quality database design is important, even in RoR.

Either way, though, I think we'll all agree that you schema, either in schema.rb or lots of migrations, needs to be part of your Rails application.

Definitely Migrations. There is a reason why it is in there. It is databasesystem independent, highly flexible and consistent to use within Rails

As is often the case when working with Rails, "convention over configuration" is the way to go. The migration system is in place to allow to you abstract your model away from your database, and makes your project far more portable.

By using migrations, you are making sure that your application always knows about your database in a clear and consistent way, and you make it easy for others to add to and extend your application in a manner that is easier to merge back in later.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM