Database migration

J

Jerry Jones

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 :password, :string, :limit => 32
table.column :email, :string
end
end

def self.down
drop_table :users
end
end
 
D

David Goodlad

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 :password, :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
 
M

Mike Harris

Jerry said:
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 :password, :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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top