Database migration

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

On 2/5/07, Jerry J. [email protected] wrote:

Beginner alert…

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

    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

Jerry J. wrote:

   table.column :login,  :string

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs