Hi All,
I running Ruby/Rails versions:
ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]
Rails 2.0.2
I ran:
ruby script/generate scaffold Payroll string:Client_Code
and got 001_create_payrolls.rb:
class CreatePayrolls < ActiveRecord::Migration
def self.up
create_table :payrolls do |t|
t.Client_Code :string
t.timestamps
end
end
def self.down
drop_table :payrolls
end
end
I didn’t want to add all the variables I wanted to the scaffold
invocation. So I created a second migration 002_create_payrolls.rb:
class CreatePayrolls < ActiveRecord::Migration
def self.up
create_table :payrolls do |t|
t.Client_Code :string
t.Date :date
[snip]
t.EE_Num :integer
t.timestamps
end
end
def self.down
drop_table :payrolls
end
end
Here’s the problem. I ran:
rake db:migrate
and got:
-- create_table(:payrolls)
rake aborted!
undefined method `Client_Code' for
#<ActiveRecord::ConnectionAdapters::TableDefinition:0x3154278>
I thought the problem might be that 001 created the payrolls database,
and 002 did the same thing ... an obvious conflict. So I modified 002
to precede the create_table statement with:
drop_table(:payrolls)
That gave me:
== 2 CreatePayrolls: migrating =======================================
-- drop_table(:payrolls)
rake aborted!
SQLite3::SQLException: no such table: payrolls: DROP TABLE payrolls
I tried running with the –trace option but it failed immediately the
same way.
I realize I could just replace 001's content with 002's and discarding
002. Or I could switch 002 to add_column statements. But I'd like
to learn how these multiple migrations work.
Any observations would be most appreciated.
TIA,
Richard
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---