More migration issues

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:
[email protected]:~/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.

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. [email protected] 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:
[email protected]:~/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.

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs