Manish Shah
2006-Mar-08 05:07 UTC
[Rails] migrations schema_info table, Rails Recipes Bug?
I have the rails recipes book and i was going through the migrations recipe. Everything seemed to work except for the last part in trying to do a rake migrate with a migration file version 1 and the schema_info version set to 0. Without the force attribute, the rake migration fails, as expected. So the recipe says to run this: ruby script/runner ''ActiveRecord::Base.connection.execute("INSERT INTO schema_info (version) VALUES(1)")'' with an INSERT function. however, it said the schema_info table is just 1 column, 1 row. Is this true? Cause if that is true, shouldnt the command be to "UPDATE" the version to 1, not inserting another row? I guess my confusion lies in the definition of schema_info. I think it makes sense to be just one column, one row, but i''m just a simple minded programmer. But anyway, my rake migrations kept failing until i switched to the update command: ruby script/runner ''ActiveRecord::Base.connection.execute("UPDATE schema_info SET version=1")'' I know its a beta book, so i''m looking to confirm if this is a bug or not. Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060308/8ec21c6b/attachment.html
Chad Fowler
2006-Mar-08 17:59 UTC
[Rails] migrations schema_info table, Rails Recipes Bug?
On 3/7/06, Manish Shah <mnshah@gmail.com> wrote:> I have the rails recipes book and i was going through the migrations recipe. > Everything seemed to work except for the last part in trying to do a rake > migrate with a migration file version 1 and the schema_info version set to > 0. Without the force attribute, the rake migration fails, as expected. > > So the recipe says to run this: > > ruby script/runner ''ActiveRecord::Base.connection.execute("INSERT INTO > schema_info (version) VALUES(1)")'' > > with an INSERT function. however, it said the schema_info table is just 1 > column, 1 row. Is this true? Cause if that is true, shouldnt the command > be to "UPDATE" the version to 1, not inserting another row? > > I guess my confusion lies in the definition of schema_info. I think it > makes sense to be just one column, one row, but i''m just a simple minded > programmer. > > But anyway, my rake migrations kept failing until i switched to the update > command: > > ruby script/runner ''ActiveRecord::Base.connection.execute("UPDATE > schema_info SET version=1")'' > > I know its a beta book, so i''m looking to confirm if this is a bug or not. >Thanks, Manish. I think you''re right. I need to go back through and make sure that this follows the same flow that I did in the Recipe. Your comments are appreciated! -- Chad Fowler http://chadfowler.com http://pragmaticprogrammer.com/titles/fr_rr/ (Rails Recipes - In Beta!) http://pragmaticprogrammer.com/titles/mjwti/ (My Job Went to India, and All I Got Was This Lousy Book) http://rubycentral.org http://rubygarden.org http://rubygems.rubyforge.org (over one million gems served!)
Chris Taggart
2006-Mar-08 22:45 UTC
[Rails] migrations schema_info table, Rails Recipes Bug?
I had this very same prob today, but there was some mention on the user-submitted errata of deleting the 0 (leaving just the 1) -- which I did and this solved the prob., and I''ve since done another migration without any probs, so that seems the prob. Chris T [Good book apart from that, and well worth the money] Chad Fowler wrote:> On 3/7/06, Manish Shah <mnshah@gmail.com> wrote: > >> I have the rails recipes book and i was going through the migrations recipe. >> Everything seemed to work except for the last part in trying to do a rake >> migrate with a migration file version 1 and the schema_info version set to >> 0. Without the force attribute, the rake migration fails, as expected. >> >> So the recipe says to run this: >> >> ruby script/runner ''ActiveRecord::Base.connection.execute("INSERT INTO >> schema_info (version) VALUES(1)")'' >> >> with an INSERT function. however, it said the schema_info table is just 1 >> column, 1 row. Is this true? Cause if that is true, shouldnt the command >> be to "UPDATE" the version to 1, not inserting another row? >> >> I guess my confusion lies in the definition of schema_info. I think it >> makes sense to be just one column, one row, but i''m just a simple minded >> programmer. >> >> But anyway, my rake migrations kept failing until i switched to the update >> command: >> >> ruby script/runner ''ActiveRecord::Base.connection.execute("UPDATE >> schema_info SET version=1")'' >> >> I know its a beta book, so i''m looking to confirm if this is a bug or not. >> >> > > Thanks, Manish. I think you''re right. I need to go back through and > make sure that this follows the same flow that I did in the Recipe. > Your comments are appreciated! > > -- > Chad Fowler > http://chadfowler.com > http://pragmaticprogrammer.com/titles/fr_rr/ (Rails Recipes - In Beta!) > http://pragmaticprogrammer.com/titles/mjwti/ (My Job Went to India, > and All I Got Was This Lousy Book) > http://rubycentral.org > http://rubygarden.org > http://rubygems.rubyforge.org (over one million gems served!) > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >
I had this very same prob today, but there was some mention on the user-submitted errata of deleting the 0 (leaving just the 1) -- which I did and this solved the prob., and I''ve since done another migration without any probs, so that seems the prob. Chris T [Good book apart from that, and well worth the money] Chad Fowler wrote:> On 3/7/06, Manish Shah <mnshah@gmail.com> wrote: > >> I have the rails recipes book and i was going through the migrations recipe. >> Everything seemed to work except for the last part in trying to do a rake >> migrate with a migration file version 1 and the schema_info version set to >> 0. Without the force attribute, the rake migration fails, as expected. >> >> So the recipe says to run this: >> >> ruby script/runner ''ActiveRecord::Base.connection.execute("INSERT INTO >> schema_info (version) VALUES(1)")'' >> >> with an INSERT function. however, it said the schema_info table is just 1 >> column, 1 row. Is this true? Cause if that is true, shouldnt the command >> be to "UPDATE" the version to 1, not inserting another row? >> >> I guess my confusion lies in the definition of schema_info. I think it >> makes sense to be just one column, one row, but i''m just a simple minded >> programmer. >> >> But anyway, my rake migrations kept failing until i switched to the update >> command: >> >> ruby script/runner ''ActiveRecord::Base.connection.execute("UPDATE >> schema_info SET version=1")'' >> >> I know its a beta book, so i''m looking to confirm if this is a bug or not. >> >> > > Thanks, Manish. I think you''re right. I need to go back through and > make sure that this follows the same flow that I did in the Recipe. > Your comments are appreciated! > > -- > Chad Fowler > http://chadfowler.com > http://pragmaticprogrammer.com/titles/fr_rr/ (Rails Recipes - In Beta!) > http://pragmaticprogrammer.com/titles/mjwti/ (My Job Went to India, > and All I Got Was This Lousy Book) > http://rubycentral.org > http://rubygarden.org > http://rubygems.rubyforge.org (over one million gems served!) > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >