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) -- Posted via http://www.ruby-forum.com/.
Berger, Daniel
2006-Jul-10 21:13 UTC
[Rails] Re: Problem with migrations, postgresql, AWDwR
> -----Original Message----- > From: rails-bounces@lists.rubyonrails.org > [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of sean lynch > Sent: Monday, July 10, 2006 2:34 PM > To: rails@lists.rubyonrails.org > Subject: [Rails] Re: Problem with migrations, postgresql, AWDwR > > > 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)I thought about that so I double checked. Yes, there is definitely a ''products'' table (I can see it via psql). The data should pass the validations, but just in case I commented all the validations out of the model, and deleted all existing rows (well, one) from the database and tried again. Still no luck, however. Any other 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.