Just going through ''agile web development with rails'' 2nd ed. I accidentally created an empty migration source file with the wrong name, ruby script/generate migration add_test_date and then straight after that created the one I wanted to use ruby script/generate migration add_test_data and populated the second one - when I ran rake db:migrate a few times it did not seem to update the table. I read something in the book about creating empty migration files, but I thought if I created a new one it should work. what should i do now? also - do i need the server running to perform migrations? cheers. -- Posted via http://www.ruby-forum.com/.
Hi Frank, answers inline: On 8/1/06, Frank Mullenger <frank_mullenger@yahoo.com> wrote:> > Just going through ''agile web development with rails'' 2nd ed. > > > I accidentally created an empty migration source file with the wrong > name, > ruby script/generate migration add_test_dateYou might want to try ruby script/destroy migration add_test_date and then straight after that created the one I wanted to use> ruby script/generate migration add_test_data > > and populated the second one - when I ran > rake db:migrate > > a few times it did not seem to update the table. I read something in the > book about creating empty migration files, but I thought if I created a > new one it should work.Yes, I think so too. What exactly is it that is not working? what should i do now? also - do i need the server running to perform> migrations?No, that isn''t necessary. cheers. Cheers, Jan --> Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060801/fbfa466c/attachment.html
Thanks, I was able to delete the add_test_date fine. So I have: db/migrate/001_create_products.rb db/migrate/002_add_price.rb db/migrate/add_test_data.rb ran rake db:migrate only output was (in C:rubyonrails/work/depot) No change to the database, and the schema_info table has version 4 in it. here is the basic file i am trying to use: ========================================================== class AddTestData < ActiveRecord::Migration def self.up Product.create(:title => ''Pragmatic Project Automation'', :description => %{<p> <em>Pragmatic Project Automation</em> shows you how to improve the consistency and repeatability of your project''s procedures using automation to reduce risk and errors. </p> <p> Simply put, we''re going to put this thing called a computer to work for you doing the mundane (but important) project stuff. That means you''ll have more time and energy to do the really exciting---and difficult---stuff, like writing quality code. </p>}, :image_url => ''/images/auto.jpg'', :price => 29.95) end def self.down Product.delete_all end end ============================================================= I don''t really know how or where it is supposed to get Product.create from? cheers Jan Prill wrote:> Hi Frank, > > answers inline: > > On 8/1/06, Frank Mullenger <frank_mullenger@yahoo.com> wrote: >> >> Just going through ''agile web development with rails'' 2nd ed. >> >> >> I accidentally created an empty migration source file with the wrong >> name, >> ruby script/generate migration add_test_date > > > You might want to try ruby script/destroy migration add_test_date > > and then straight after that created the one I wanted to use >> ruby script/generate migration add_test_data >> >> and populated the second one - when I ran >> rake db:migrate >> >> a few times it did not seem to update the table. I read something in the >> book about creating empty migration files, but I thought if I created a >> new one it should work. > > > Yes, I think so too. What exactly is it that is not working? > > what should i do now? also - do i need the server running to perform >> migrations? > > > No, that isn''t necessary. > > cheers. > > > Cheers, > Jan > > ---- Posted via http://www.ruby-forum.com/.
On 01/08/06, Frank Mullenger <frank_mullenger@yahoo.com> wrote:> Thanks, I was able to delete the add_test_date fine. So I have: > > db/migrate/001_create_products.rb > db/migrate/002_add_price.rb > db/migrate/add_test_data.rbShould the final file not be: db/migrate/003_add_test_data.rb Tom
**Sorry - I found where the create() method is for product. Umm, it should be 003, but i made a typo and created 003_add_test_date. so in fact i made another typo below (my night for typos)..it is actually... db/migrate/004_add_test_data.rb Thanks, Frank. Tom Ward wrote:> On 01/08/06, Frank Mullenger <frank_mullenger@yahoo.com> wrote: >> Thanks, I was able to delete the add_test_date fine. So I have: >> >> db/migrate/001_create_products.rb >> db/migrate/002_add_price.rb >> db/migrate/add_test_data.rb > > Should the final file not be: > > db/migrate/003_add_test_data.rb > > Tom-- Posted via http://www.ruby-forum.com/.
Hi Frank, ok, if the schema_info table corresponds to 004_... as the last file in the rake filename scheme, then it''s no wonder that no migrations are issued because the migration ''assumes'' that migration files and database are in sync. IMHO you need to set back the schema_info to ''3'' either by running rake migrate VERSION=3 or by issuing update schema_info set version = 3; on the sql command line. After that run rake db:migrate once again. Cheers, Jan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060801/f0704717/attachment.html
Hi Jan, thanks very much - thats helped me a lot. i was able to set the version to 0 or 3 or whatever and it changed the database accordingly. but still, when i ran rake db:migrate or rake db:migrate VERSION=4 the database did not get populated as I thought it would... I even changed the file to be 003_add_test_data.rb (for continuity 001,002,003...), the structure of db stays as I guess it was created in 001 and 002, but the data in 003 does not get entered. are there any log files i can check? thanks again, Frank. Jan Prill wrote:> Hi Frank, > > ok, if the schema_info table corresponds to 004_... as the last file in > the > rake filename scheme, then it''s no wonder that no migrations are issued > because the migration ''assumes'' that migration files and database are in > sync. > > IMHO you need to set back the schema_info to ''3'' either by running rake > migrate VERSION=3 or by issuing update schema_info set version = 3; on > the > sql command line. After that run rake db:migrate once again. > > Cheers, > Jan-- Posted via http://www.ruby-forum.com/.
Is there anything in your development.log according to the migration? Are you able to issue the Product.create ... on the console via RAILS_ROOT>ruby script/console? Cheers, Jan On 8/1/06, Frank Mullenger <frank_mullenger@yahoo.com> wrote:> > Hi Jan, > > thanks very much - thats helped me a lot. i was able to set the version > to 0 or 3 or whatever and it changed the database accordingly. but > still, when i ran rake db:migrate or rake db:migrate VERSION=4 the > database did not get populated as I thought it would... > > I even changed the file to be 003_add_test_data.rb (for continuity > 001,002,003...), the structure of db stays as I guess it was created in > 001 and 002, but the data in 003 does not get entered. > > are there any log files i can check? > > thanks again, > Frank. > > > Jan Prill wrote: > > Hi Frank, > > > > ok, if the schema_info table corresponds to 004_... as the last file in > > the > > rake filename scheme, then it''s no wonder that no migrations are issued > > because the migration ''assumes'' that migration files and database are in > > sync. > > > > IMHO you need to set back the schema_info to ''3'' either by running rake > > migrate VERSION=3 or by issuing update schema_info set version = 3; on > > the > > sql command line. After that run rake db:migrate once again. > > > > Cheers, > > Jan > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060801/25020fb5/attachment.html
Hi, Sorry I had to quit last night as it was getting late. Here is the only relevant stuff in the log I think... [4;36;1mSQL (0.000000) [0;1mMysql::Error: Table ''schema_info'' already exists: CREATE TABLE schema_info (version int(11)) [4;35;1mSQL (0.000000) Mysql::Error: Table ''schema_info'' already exists: CREATE TABLE schema_info (version int(11)) [4;36;1mSQL (0.000000) [0;1mSELECT version FROM schema_info [4;35;1mSQL (0.000000) SELECT version FROM schema_info [4;36;1mSQL (0.000000) [0;1mSELECT version FROM schema_info [4;35;1mSQL (0.000000) SELECT * FROM schema_info [4;36;1mSQL (0.000000) [0;1mSHOW TABLES [4;35;1mSQL (0.016000) SHOW FIELDS FROM products [4;36;1mSQL (0.000000) [0;1mSHOW KEYS FROM products I doesn''t really like running the Product.create command. With no arguments it gives validation errors which makes sense, but with all the correct values it just goes onto the next line of the prompt without putting info in db? Jan Prill wrote:> Is there anything in your development.log according to the migration? > > Are you able to issue the Product.create ... on the console via > RAILS_ROOT>ruby script/console? > > Cheers, > Jan-- Posted via http://www.ruby-forum.com/.
On 8/2/06, Frank Mullenger <frank_mullenger@yahoo.com> wrote:> > Hi, > > Sorry I had to quit last night as it was getting late. Here is the only > relevant stuff in the log I think... > > [4;36;1mSQL (0.000000) [0;1mMysql::Error: Table ''schema_info'' > already exists: CREATE TABLE schema_info (version int(11)) > [4;35;1mSQL (0.000000) Mysql::Error: Table ''schema_info'' > already exists: CREATE TABLE schema_info (version int(11)) > [4;36;1mSQL (0.000000) [0;1mSELECT version FROM > schema_info > [4;35;1mSQL (0.000000) SELECT version FROM schema_info > [4;36;1mSQL (0.000000) [0;1mSELECT version FROM > schema_info > [4;35;1mSQL (0.000000) SELECT * FROM schema_info > [4;36;1mSQL (0.000000) [0;1mSHOW TABLES > [4;35;1mSQL (0.016000) SHOW FIELDS FROM products > [4;36;1mSQL (0.000000) [0;1mSHOW KEYS FROM products > > I doesn''t really like running the Product.create command. With no > arguments it gives validation errors which makes sense, but with all the > correct values it just goes onto the next line of the prompt without > putting info in db? > >Ok if I understand this right than you had no luck in creating products on the command line either? Than you need to find your problem there. Why isn''t ActiveRecord working? There''s got to be a problem with your model. Doesn''t your log tell you something about this. What''s with a simple scaffolding ''new'' of the Product. Does this work? Your migration won''t have any effect on the database as long as your Product.create command won''t have any effect on the db either... Cheers, Jan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060802/7390dc3e/attachment.html
I had a similar problem--no typos but running "rake db:migrate" didn''t seem to populate any data. Try running rake db:migrate VERSION=4 That worked for me and populated all the data. -Toby Frank Mullenger wrote:> Hi Jan, > > thanks very much - thats helped me a lot. i was able to set the version > to 0 or 3 or whatever and it changed the database accordingly. but > still, when i ran rake db:migrate or rake db:migrate VERSION=4 the > database did not get populated as I thought it would... > > I even changed the file to be 003_add_test_data.rb (for continuity > 001,002,003...), the structure of db stays as I guess it was created in > 001 and 002, but the data in 003 does not get entered. > > are there any log files i can check? > > thanks again, > Frank. > > > Jan Prill wrote: >> Hi Frank, >> >> ok, if the schema_info table corresponds to 004_... as the last file in >> the >> rake filename scheme, then it''s no wonder that no migrations are issued >> because the migration ''assumes'' that migration files and database are in >> sync. >> >> IMHO you need to set back the schema_info to ''3'' either by running rake >> migrate VERSION=3 or by issuing update schema_info set version = 3; on >> the >> sql command line. After that run rake db:migrate once again. >> >> Cheers, >> Jan-- Posted via http://www.ruby-forum.com/.