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
Starting at the right place will probably help: rails-users for rails,
ruby-talk for ruby ‘in general’
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.