How to use Rails Migrations - Part I  Hot PDF Print E-mail
Tag it:
Delicious
Furl it!
Digg
NewsVine
Reddit
YahooMyWeb
Technorati
Articles Reviews Ruby
Written by Yavor Ivanov   
Wednesday, 21 March 2007

{mos_sb_discuss:50}

This article is part one of the series about Rails Migrations and it will explain on a basic level how to use the Ruby on Rails migrations. 


1. What are Migrations ?

Migrations in Rails is a way of describing what the database should look like and synchronize it with the respective model.

Migrations are abstract to the database they are used with. This means that if you have used a MySQL database server when developing the application and the production database server is different let’s say Postgresql the database you defined within the migrations will remain intact and will run just fine on the new database server.

Migrations provide a way to make the database development SVN like… I will cover this latter on so just keep in mind this for now.
 
2. Creating and Running Migrations

A migration is a simple Ruby file in the db/migrate directory.


Each migration file has a name starting with three digits and an underscore. Those digits are the representation of the migrations version (a bit like SVN), because they define the sequence in which the migrations are applied.

To generate a migration type:

ruby script/generate model user

Read more


User reviews

There are no user reviews for this item.

Add new review




Powered by jReviews

Last Updated ( Wednesday, 21 March 2007 )
 
< Prev   Next >