Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Database migration

Reply
Thread Tools

Database migration

 
 
Jerry Jones
Guest
Posts: n/a
 
      02-06-2007
Beginner alert.....
I am working on a database migration. I am adding inventory items to
the table. I have the data, but for the life of me, I cannot remember
where to make this file. I remember how to run the migration etc.
So where do I put the

class AddUserTable < ActiveRecord::Migration
def self.up
create_table :users do |table|
table.column :name, :string
table.column :login, :string
table.column assword, :string, :limit => 32
table.column :email, :string
end
end

def self.down
drop_table :users
end
end

 
Reply With Quote
 
 
 
 
David Goodlad
Guest
Posts: n/a
 
      02-06-2007
On 2/5/07, Jerry Jones <> wrote:
> Beginner alert.....


Starting at the right place will probably help: rails-users for rails,
ruby-talk for ruby 'in general'

> I am working on a database migration. I am adding inventory items to
> the table. I have the data, but for the life of me, I cannot remember
> where to make this file. I remember how to run the migration etc.
> So where do I put the
>
> class AddUserTable < ActiveRecord::Migration
> def self.up
> create_table :users do |table|
> table.column :name, :string
> table.column :login, :string
> table.column assword, :string, :limit => 32
> table.column :email, :string
> end
> end
>
> def self.down
> drop_table :users
> end
> end


I'd suggest using the generator script to give you a good place to put
your migrations - in fact, it works well for almost every file that
you need to add. In this case:

/script/generate migration add_user_table

This would generate db/migrate/001_add_user_table.rb, into which you'd
place that code that you posted.

Dave

--
Dave Goodlad
or
http://david.goodlad.ca/

 
Reply With Quote
 
 
 
 
Mike Harris
Guest
Posts: n/a
 
      02-06-2007
Jerry Jones wrote:

> Beginner alert.....
> I am working on a database migration. I am adding inventory items to
> the table. I have the data, but for the life of me, I cannot remember
> where to make this file. I remember how to run the migration etc.
> So where do I put the
>
> class AddUserTable < ActiveRecord::Migration
> def self.up
> create_table :users do |table|
> table.column :name, :string
> table.column :login, :string
> table.column assword, :string, :limit => 32
> table.column :email, :string
> end
> end
>
> def self.down
> drop_table :users
> end
> end
>
>

The db\migrate folder. Make a migration with ruby script\generate
migration AddUserTable.

Read the docs (http://api.rubyonrails.com) and please direct further
questions to the Rails mailing list.

 
Reply With Quote
 
 
 
Reply

Thread Tools

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Database Database Database Database scott93727@gmail.com Computer Information 0 09-27-2012 02:43 AM
DataBase DataBase DataBase DataBase scott93727@gmail.com Computer Information 0 09-26-2012 09:40 AM
Database to xml for data migration Cameron Senior Ruby 3 12-10-2007 10:10 AM
database migration V Cisco 1 06-16-2007 03:48 PM
old database migration to java john doe Java 1 02-03-2004 03:20 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57