# Rake migration not working

**URL:** <https://www.ruby-forum.com/t/rake-migration-not-working/71702>\
**Category:** Rails\
**Created:** [October 10, 2006, 10:41pm UTC](https://www.ruby-forum.com/t/rake-migration-not-working/71702 "2006-10-10T22:41:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![railrocks](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c4cdca/32.png) [@railrocks](https://www.ruby-forum.com/u/railrocks)\
**Post date:** [October 10, 2006, 10:41pm UTC](https://www.ruby-forum.com/t/rake-migration-not-working/71702/1 "2006-10-10T22:41:51Z")

</div>

This is my first project with rails. I am following the book of Curt  
Hibbs and Bruce Tate. the book is called Ruby on rails: up and running.

I built eight different models for eight tables using ruby  
script/generate model …

Then I went to db/migrate and introduced my columns for each \*.rb file.

When I do rake migrate only two tables get created on my persoal oracle  
database. Rest of them do not get created. I see schema.rb in db  
directory and I can only see 2 tables created.  
create\_table “am\_ba\_departments”, :force =\> true do |t|  
t.column “department\_name”, :string  
t.column “created\_on”, :datetime  
t.column “created\_at”, :time  
t.column “updated\_on”, :datetime  
t.column “updated\_at”, :time  
t.column “lock\_version”, :integer  
end

create\_table “am\_software\_categories”, :force =\> true do |t|  
t.column “software\_category”, :string  
t.column “created\_on”, :datetime  
t.column “created\_at”, :time  
t.column “updated\_on”, :datetime  
t.column “updated\_at”, :time  
t.column “lock\_version”, :integer  
end

Am I doing something wrong or is there a bug in rake.  
Any help would be appreciated. If needed I can provide more specific  
information.

---

<div class="post-metadata">

**Author:** ![railrocks](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c4cdca/32.png) [@railrocks](https://www.ruby-forum.com/u/railrocks)\
**Post date:** [October 10, 2006, 11:18pm UTC](https://www.ruby-forum.com/t/rake-migration-not-working/71702/2 "2006-10-10T23:18:49Z")

</div>

Did you run rake befor you were finished with your migrations ? This is  
easily done, and once rake has run a migration one it won’t (by itself)  
run those migrations again, even if you have changed them. The easiest  
thing to do is probably to blow away the contents of your database.

Fred

---

<div class="post-metadata">

**Author:** ![railrocks](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c4cdca/32.png) [@railrocks](https://www.ruby-forum.com/u/railrocks)\
**Post date:** [October 11, 2006, 1:05am UTC](https://www.ruby-forum.com/t/rake-migration-not-working/71702/3 "2006-10-11T01:05:20Z")

</div>

Rakesh Malhotra \<rails-mailing-list@…\> writes:

> When I do rake migrate only two tables get created on my persoal  
> oracle  
> database. Rest of them do not get created. I see schema.rb in db  
> directory and I can only see 2 tables created.

Are these in one migration or multiple migrations?

There were no error messages when you ran the Rake task?

Run rake migrate --trace; that might give you a more detailed view of  
what’s  
going on.

BTW, I always run my migrations inside a transaction, so either it all  
works or  
nothing gets saved:  
def self.up  
ActiveRecord::Base.transaction do  
… migration stuff here  
end  
end

---

<div class="post-metadata">

**Author:** ![railrocks](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c4cdca/32.png) [@railrocks](https://www.ruby-forum.com/u/railrocks)\
**Post date:** [October 11, 2006, 6:37am UTC](https://www.ruby-forum.com/t/rake-migration-not-working/71702/4 "2006-10-11T06:37:42Z")

</div>

I believe Postgres and MS SQL Server support DDL transactions.

MySQL and Oracle do not, not sure about the others.

All of this is from memory from a discussion at RailsConf 2006.

Apologies in advance if I’m mistaken.

On Oct 10, 2006, at 8:27 PM, Ali wrote:

> > oracle  
> > BTW, I always run my migrations inside a transaction, so either it

–  
– Tom M.

---

<div class="post-metadata">

**Author:** ![railrocks](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c4cdca/32.png) [@railrocks](https://www.ruby-forum.com/u/railrocks)\
**Post date:** [October 11, 2006, 6:05am UTC](https://www.ruby-forum.com/t/rake-migration-not-working/71702/5 "2006-10-11T06:05:38Z")

</div>

Does ActiveRecord::Base.transaction support DDL transactions? I think  
most databases implicitly commit after any DDL statement. I dont think  
creating multiple tables in a transaction will be all or nothing.

Ali

---

<div class="post-metadata">

**Author:** ![railrocks](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c4cdca/32.png) [@railrocks](https://www.ruby-forum.com/u/railrocks)\
**Post date:** [October 11, 2006, 4:11pm UTC](https://www.ruby-forum.com/t/rake-migration-not-working/71702/6 "2006-10-11T16:11:26Z")

</div>

Fred wrote:

> Did you run rake befor you were finished with your migrations ? This is  
> easily done, and once rake has run a migration one it won’t (by itself)  
> run those migrations again, even if you have changed them. The easiest  
> thing to do is probably to blow away the contents of your database.
> 
> Fred

Hi Fred,

```
 I created all the migrations and then I gave the command rake 

```

migration.  
I also ran rake migrate --trace  
I get the following output

C:\InstantRails\InstantRails\rails\_apps\asset\>rake migrate --trace  
(in C:/InstantRails/InstantRails/rails\_apps/asset)  
\*\* Invoke migrate (first\_time)  
\*\* Invoke db:migrate (first\_time)  
\*\* Invoke environment (first\_time)  
\*\* Execute environment  
\*\* Execute db:migrate  
\*\* Invoke db:schema:dump (first\_time)  
\*\* Invoke environment  
\*\* Execute db:schema:dump  
\*\* Execute migrate

I have 8 migration scripts but rake picks up only two of them. Few of my  
other migration scripts define many to many relation. For example I have  
two tables am\_applications and am\_developers.

For these two tables, I have two scripts.

The first 001\_create\_am\_applications.rb is as follows

class CreateAmApplications \< ActiveRecord::Migration  
def self.up  
create\_table :am\_applications do |t|  
t.column :business\_application\_name, :string  
t.column :developed\_by, :string  
t.column :maintained\_by, :string  
t.column :exposed\_on\_openview, :string  
t.column :primary\_contact, :string  
t.column :backup\_contact, :string  
t.column :remarks, :string  
t.column :created\_on, :datetime  
t.column :created\_at, :datetime  
t.column :updated\_on, :datetime  
t.column :updated\_at, :datetime  
t.column :lock\_version, :integer  
end  
end

def self.down  
drop\_table :am\_applications  
end  
end

The second one 003\_create\_am\_developers.rb is as follows  
class CreateAmDevelopers \< ActiveRecord::Migration  
def self.up  
create\_table :am\_developers do |t|  
t.column :name, :string  
t.column :software\_expertise, :string  
t.column :application\_expertise, :string  
t.column :other\_expertise, :string  
t.column :remarks, :string  
t.column :created\_on, :datetime  
t.column :created\_at, :datetime  
t.column :updated\_on, :datetime  
t.column :updated\_at, :datetime  
t.column :lock\_version, :integer  
end  
create\_table(“am\_applications\_am\_developers”, :id=\>false) do |t|  
t.column “am\_application\_id”, :integer  
t.column “am\_developer\_id”, :integer  
end  
end

def self.down  
drop\_table :am\_developers  
end  
end

Note that I introduced the join table between application and developers  
in the same class as CreateAmdeveloepers.

So when I do rake migrate the above two and other tables having same  
relationship do not get migrated.

I was wondering if defining the migration scripts in above format is the  
cause or there is nothing wrong with the way migration scripts are  
created and there could be problems with rake?

---

<div class="post-metadata">

**Author:** ![railrocks](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c4cdca/32.png) [@railrocks](https://www.ruby-forum.com/u/railrocks)\
**Post date:** [October 11, 2006, 12:22pm UTC](https://www.ruby-forum.com/t/rake-migration-not-working/71702/7 "2006-10-11T12:22:45Z")

</div>

Tom M. wrote:

> I believe Postgres and MS SQL Server support DDL transactions.
> 
> MySQL and Oracle do not, not sure about the others.
> 
> All of this is from memory from a discussion at RailsConf 2006.
> 
> Apologies in advance if I’m mistaken.
> 
> On Oct 10, 2006, at 8:27 PM, Ali wrote:
> 
> > > oracle  
> > > BTW, I always run my migrations inside a transaction, so either it
> 
> –  
> – Tom M.

SQL Server definately supports DDL transactions and in 2005 even DLL  
triggers…
