Problem with migrations, postgresql, AWDwR

Hi all,

Rails 1.1.4
Rake 0.7.1
PostgreSQL 8.1.4
Windows XP Pro

I checked for errata on pragmaticprogrammer.com, but didn’t see any
explicit mention of this issue.

I’m going over the depot example in AWDwR, 2nd ed, and I can’t get the
migration to work on p. 82. Specifically, the AddTestData example (with
reduced description text to save my fingers some typing):

class AddTestData < ActiveRecord::Migration
def self.up
Product.create(
:title => ‘Pragmatic Version Control’,
:description => ‘Some test data’,
:image_url => ‘/images/svn.png’,
:price => 2850
)
end

def self.down
Product.delete_all
end
end

After running ‘rake db:migrate’…nothing happens. There is no error,
but there is no data in the database, either. Tailing the log file
didn’t reveal anything beyond the sql used to check the schema_info
table. I tried adding an explicit .save as well, but that still didn’t
work. The first two migration examples worked fine, btw, those were DDL
style migrations.

Any ideas?

Thanks,

Dan

This communication is the property of Qwest and may contain confidential
or
privileged information. Unauthorized use of this communication is
strictly
prohibited and may be unlawful. If you have received this communication
in error, please immediately notify the sender by reply e-mail and
destroy
all copies of the communication and any attachments.

Berger, Daniel wrote:

class AddTestData < ActiveRecord::Migration
def self.up
Product.create(
:title => ‘Pragmatic Version Control’,
:description => ‘Some test data’,
:image_url => ‘/images/svn.png’,
:price => 2850
)
end

def self.down
Product.delete_all
end
end

After running ‘rake db:migrate’…nothing happens. There is no error,
but there is no data in the database, either. Tailing the log file
didn’t reveal anything beyond the sql used to check the schema_info
table. I tried adding an explicit .save as well, but that still didn’t
work. The first two migration examples worked fine, btw, those were DDL
style migrations.

Any ideas?

Thanks,

Dan

The table was already created on a previous migration?
Do you have any validations in your model?
Does the data you are trying to input pass the validations? (I know
these are silly questions, but that’s where I usually mess things up)

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