Hi,
I'm creating a simple Migration that adds test data to my database.
A Form has many Elements and every Element belongs to a Form. An element has
the mandatory columns name, type and value.
---
class AddTestData < ActiveRecord::Migration
def self.up
Form.delete_all
Element.delete_all
bert = Form.create(:name => "Bert's Form")
Element.create(:form => bert, :name => 'First Name', :type => 'text',
:value => '')
Element.create(:form => bert, :name => 'Last Name', :type => 'text',
:value => '')
ernie = Form.create(:name => "Ernie's Form")
Element.create(:form => ernie, :name => 'Your Name', :type => 'text',
:value => '')
Element.create(:form => ernie, :name => 'E-mail', :type => 'text',
:value => '')
end
def self.down
Form.delete_all
Element.delete_all
end
end
---
Gives the error:
Mysql::Error: #23000Column 'type' cannot be null: INSERT INTO `elements`
(`form_id`, `ordering`, `name`, `title`, `type`, `value`, `flags`,
`created_at`, `updated_at`) VALUES(2, NULL, 'First Name', NULL, NULL, '',
NULL, '2008-09-16 13:59:36', '2008-09-16 13:59:36')
As you can see, the 'type' column somehow isn't inserted.
I had similar issues when trying to add a column called 'timestamp'.
Best regards,
CmdJohnson
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---