# More migration issues

**URL:** <https://www.ruby-forum.com/t/more-migration-issues/69856>\
**Category:** Rails\
**Created:** [September 25, 2006, 2:18am UTC](https://www.ruby-forum.com/t/more-migration-issues/69856 "2006-09-25T02:18:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hotgazpacho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a587f6/32.png) [@hotgazpacho](https://www.ruby-forum.com/u/hotgazpacho)\
**Post date:** [September 25, 2006, 2:18am UTC](https://www.ruby-forum.com/t/more-migration-issues/69856/1 "2006-09-25T02:18:54Z")

</div>

I’ve been using Rake to migrate my database schema as I work on it to  
make deployment easier later on. I tried to add a session table as  
follows:

rake db:sessions:create

and it appears to have worked fine.

However, now rake migrate fails with the following error:  
wgant@will:~/user/ruby/HoshinWeb$ rake migrate  
(in /home/wgant/user/ruby/HoshinWeb)  
rake aborted!  
uninitialized constant CreateUserRoles

I have a file called 010\_Create\_User\_Roles. Interestingly enough, when I  
remove this file, the migration works just fine. Below are the contents  
of the file.

class UserRoles \< ActiveRecord::Migration  
def self.up  
create\_table “user\_roles” do |t|  
t.column “user\_id”, :int  
t.column “role\_id”, :int  
end  
end

def self.down  
drop\_table “user\_roles”  
end  
end

Can anyone see why this one is failing? I’m comparing it to my other  
files and I don’t see any differences. This is the first many-to-many  
join table in the migration though. Could that be the problem?

* * *

Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+  
countries) for 2Â¢/min or less.

---

<div class="post-metadata">

**Author:** ![hotgazpacho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a587f6/32.png) [@hotgazpacho](https://www.ruby-forum.com/u/hotgazpacho)\
**Post date:** [September 25, 2006, 2:34am UTC](https://www.ruby-forum.com/t/more-migration-issues/69856/2 "2006-09-25T02:34:55Z")

</div>

I figured it out. Apparently when the rake migrate task runs, it  
attempts to come up with a class name based on the name of the file. I  
may have mistakenly changed the class name at some point. Anyway, when I  
changed it back to CreateUserRoles, everything worked perfectly.

Will G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote: I’ve been using Rake to  
migrate my database schema as I work on it to make deployment easier  
later on. I tried to add a session table as follows:

rake db:sessions:create

and it appears to have worked fine.

However, now rake migrate fails with the following error:  
wgant@will:~/user/ruby/HoshinWeb$ rake migrate  
(in /home/wgant/user/ruby/HoshinWeb)  
rake aborted!  
uninitialized constant CreateUserRoles

I have a file called 010\_Create\_User\_Roles. Interestingly enough, when I  
remove this file, the migration works just fine. Below are the contents  
of the file.

class UserRoles \< ActiveRecord::Migration  
def self.up  
create\_table “user\_roles” do |t|  
t.column “user\_id”, :int  
t.column “role\_id”, :int  
end  
end

def self.down  
drop\_table “user\_roles”  
end  
end

Can anyone see why this one is failing? I’m comparing it to my other  
files and I don’t see any differences. This is the first many-to-many  
join table in the migration though. Could that be the problem?

* * *

Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+  
countries) for 2Â¢/min or less.

(What is best in life?) To crush your enemies, see them driven before  
you, and to hear the lamentations of the women. - Conan the Barbarian

* * *

Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low  
rates.

---

<div class="post-metadata">

**Author:** ![hotgazpacho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a587f6/32.png) [@hotgazpacho](https://www.ruby-forum.com/u/hotgazpacho)\
**Post date:** [September 25, 2006, 2:38am UTC](https://www.ruby-forum.com/t/more-migration-issues/69856/3 "2006-09-25T02:38:55Z")

</div>

Hi~

On Sep 24, 2006, at 5:15 PM, Will G. wrote:

> (in /home/wgant/user/ruby/HoshinWeb)  
> t.column “user\_id”, :int  
> other files and I don’t see any differences. This is the first many-  
> to-many join table in the migration though. Could that be the problem?

```
It is failing because the class name does not match the filename.

```

Are you using the generator to add the migration classes? It will  
create the right filenames and classnames for you. I say delete that  
migration and regenerate it and fill it in again:

script/generate migration create\_user\_roles

-Ezra
