IT Community - Software Programming, Web Development and Technical Support

How to Migrate DB

This is a discussion on How to Migrate DB within the Ruby forums, part of the Web Development category; I am new to Ruby on Rails I have Problem while migrating Db Can someone Plz explain...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > Ruby

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 03-14-2007, 02:45 AM
Anandavinayagam Anandavinayagam is offline
D-Web Sr.Programmer
 
Join Date: Mar 2007
Posts: 131
Anandavinayagam is on a distinguished road
Default How to Migrate DB

I am new to Ruby on Rails

I have Problem while migrating Db

Can someone Plz explain
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-16-2007, 03:15 AM
Karpagarajan Karpagarajan is offline
D-Web Analyst
 
Join Date: Mar 2007
Posts: 299
Karpagarajan is on a distinguished road
Thumbs up Re: How to Migrate DB

There are lot in migration. I have given the sample for db migration.

ActiveRecordMigration allows you to use Ruby to define changes to your database schema, making it possible to use a version control system to keep things synchronised with the actual code.

This has many uses, including:
  • Teams of developers – if one person makes a schema change, the other developers just need to update, and run “rake migrate”.
  • Production servers – run “rake migrate” when you roll out a new release to bring the database up to date as well.
  • Multiple machines – if you develop on both a desktop and a laptop, or in more than one location, migrations can help you keep them all synchronised.

Create the migration
Run the generator:
ruby script/generate migration add_a_new_table

This will create the file db/migrate/001_add_a_new_table.rb

Edit the code to tell it what to do.
The method self.up is used when migrating to a new version, self.down is used to roll back any changes if needed. The class name needs to be the same as the migration name (i.e. db/migrate/001_add_a_new_table needs a class name of AddANewTable).

The ID column will be created automatically, so don’t do it here as well.

class AddANewTable < ActiveRecord::Migration
def self.up
create_table :users do |table|
table.column :name, :string
table.column :login, :string, :null => false
# This column will contain an MD5 hash.
table.column : password, :string, :limit => 32, :null => false
table.column :email, :string
end
end

def self.down
drop_table :users
end
end

Valid column types are integer, float, datetime, date, timestamp, time, text, string, binary, and boolean.

You can also populate or modify data in a migration. A common usage would be to populate the values in a lookup table:

def self.up
create_table :statuses do |t|
t.column :name, :string
end

Status.create :name=>"Complete"
Status.create :name=>"Incomplete"

end


Run the migration
rake db:migrate

Hope the above steps will help you to solve the problem. Or give me the detailed explanation about your problem which you have faced in migration.

thanks
__________________
Karpagarajan. R
Necessity is the mother of invention
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-19-2007, 02:48 AM
Anandavinayagam Anandavinayagam is offline
D-Web Sr.Programmer
 
Join Date: Mar 2007
Posts: 131
Anandavinayagam is on a distinguished road
Default Re: How to Migrate DB

Thanks for ur reply...

I have done the migration with some samples..like urs..
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Migrate MS Access data to Oracle it.wily Database Support 4 09-14-2007 05:21 AM


All times are GMT -7. The time now is 01:50 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0