# Rake migrate problem

**URL:** <https://www.ruby-forum.com/t/rake-migrate-problem/84431>\
**Category:** Rails\
**Created:** [February 4, 2007, 2:43pm UTC](https://www.ruby-forum.com/t/rake-migrate-problem/84431 "2007-02-04T14:43:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![doucie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/71c47a/32.png) [@doucie](https://www.ruby-forum.com/u/doucie)\
**Post date:** [February 4, 2007, 2:43pm UTC](https://www.ruby-forum.com/t/rake-migrate-problem/84431/1 "2007-02-04T14:43:05Z")

</div>

I’ve created this migrate file. I run rake migrate from the prompt but  
it does not create a table. Any ideas?

class CreateUsers \< ActiveRecord::Migration  
def self.up  
create\_table :users do |t|  
t.column :login, :string  
t.column :password, :string  
t.column :email, :string  
end  
add\_column :new\_queries, :user\_id, :integer  
end

def self.down  
drop\_table :users  
remove\_column :new\_queries, :user\_id  
end  
end

---

<div class="post-metadata">

**Author:** ![doucie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/71c47a/32.png) [@doucie](https://www.ruby-forum.com/u/doucie)\
**Post date:** [February 4, 2007, 6:05pm UTC](https://www.ruby-forum.com/t/rake-migrate-problem/84431/2 "2007-02-04T18:05:53Z")

</div>

I take it this is down throught the prompt? What are the commands?

---

<div class="post-metadata">

**Author:** ![doucie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/71c47a/32.png) [@doucie](https://www.ruby-forum.com/u/doucie)\
**Post date:** [February 4, 2007, 7:13pm UTC](https://www.ruby-forum.com/t/rake-migrate-problem/84431/3 "2007-02-04T19:13:03Z")

</div>

in your Rails app path  
to drop all your migration to the start point: rake db:migrate  
VERSION=0  
to bring up the db: rake db:migrate

To roll the database back to a previous migration version: rake  
db:migrate VERSION=X

---

<div class="post-metadata">

**Author:** ![doucie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/71c47a/32.png) [@doucie](https://www.ruby-forum.com/u/doucie)\
**Post date:** [February 4, 2007, 3:49pm UTC](https://www.ruby-forum.com/t/rake-migrate-problem/84431/4 "2007-02-04T15:49:43Z")

</div>

Hi –

On Sun, 4 Feb 2007, doucie wrote:

> end  
> add\_column :new\_queries, :user\_id, :integer  
> end
> 
> def self.down  
> drop\_table :users  
> remove\_column :new\_queries, :user\_id  
> end  
> end

If it’s not giving you an error message, but also not saying it’s  
creating a table, that probably means it’s not running the migration,  
and that probably means that for some reason it thinks it’s already  
done that migration. You’d have to migrate down and back up again  
(and fix any inconsistencies by hand).

David

–  
Q. What is THE Ruby book for Rails developers?  
A. RUBY FOR RAILS by David A. Black ([Ruby for Rails](http://www.manning.com/black))  
(See what readers are saying! [http://www.rubypal.com/r4rrevs.pdf](http://www.rubypal.com/r4rrevs.pdf))  
Q. Where can I get Ruby/Rails on-site training, consulting, coaching?  
A. Ruby Power and Light, LLC ([http://www.rubypal.com](http://www.rubypal.com))

---

<div class="post-metadata">

**Author:** ![doucie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/71c47a/32.png) [@doucie](https://www.ruby-forum.com/u/doucie)\
**Post date:** [February 4, 2007, 9:08pm UTC](https://www.ruby-forum.com/t/rake-migrate-problem/84431/5 "2007-02-04T21:08:17Z")

</div>

I’ve deleted my other table and ran rake migrate again. This has  
worked. Both tables have been created. Any dangers of doing this?

---

<div class="post-metadata">

**Author:** ![doucie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/71c47a/32.png) [@doucie](https://www.ruby-forum.com/u/doucie)\
**Post date:** [February 4, 2007, 9:05pm UTC](https://www.ruby-forum.com/t/rake-migrate-problem/84431/6 "2007-02-04T21:05:28Z")

</div>

I’ve done the rake db:migrate VERSION=0.  
There was not a response in the promp other than giving the directory  
where the app is stored. I still had the schema and users table.

---

<div class="post-metadata">

**Author:** ![doucie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/71c47a/32.png) [@doucie](https://www.ruby-forum.com/u/doucie)\
**Post date:** [February 5, 2007, 10:11pm UTC](https://www.ruby-forum.com/t/rake-migrate-problem/84431/7 "2007-02-05T22:11:19Z")

</div>

Deleting the tables and remigrating shouldn’t cause any problems (as  
long as you don’t care about the data).

The schema table keeps track of migrations, so by deleting it and  
everything else you should be at square one.
