# Database migration

**URL:** <https://www.ruby-forum.com/t/database-migration/84577>\
**Category:** Ruby\
**Created:** [February 6, 2007, 2:40am UTC](https://www.ruby-forum.com/t/database-migration/84577 "2007-02-06T02:40:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jerryjj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9d8465/32.png) [@jerryjj](https://www.ruby-forum.com/u/jerryjj)\
**Post date:** [February 6, 2007, 2:40am UTC](https://www.ruby-forum.com/t/database-migration/84577/1 "2007-02-06T02:40:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jerryjj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9d8465/32.png) [@jerryjj](https://www.ruby-forum.com/u/jerryjj)\
**Post date:** [February 6, 2007, 8:32am UTC](https://www.ruby-forum.com/t/database-migration/84577/2 "2007-02-06T08:32:07Z")

</div>

On 2/5/07, Jerry J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Beginner alert…

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.

Dave

---

<div class="post-metadata">

**Author:** ![jerryjj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9d8465/32.png) [@jerryjj](https://www.ruby-forum.com/u/jerryjj)\
**Post date:** [February 6, 2007, 5:56pm UTC](https://www.ruby-forum.com/t/database-migration/84577/3 "2007-02-06T17:56:44Z")

</div>

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](http://api.rubyonrails.com)) and please direct further  
questions to the Rails mailing list.
