Good morning, I''m reading the book "Pro Active Record" by Marshall, Pytel, & Yurek. Currently stuck on chapter 3. I''m using [Ruby 1.8.6 <2007-09-24> patchlevel 111] & [Rails 2.1.1]. Chapter 3 discusses migrations. In the example provided in the book, the test scripts are created and ran outside of a Rails project. The instructions say to create a database.yml file, migrate.rb script, & database migration script. When ''ruby migrate.rb'' is ran from ms-dos, it should create the schema table in my database and also create the cows table described in the migration script. Here''s my issue, only the ''schema_migrations'' table is created in the database. The cows table described in the migration isn''t created in the database. Please review the source below and let me know if you see anything out of place. If you have time, try running the scripts yourself to see if you have better results. Thank you, Frank ------------- database.yml: ------------- development: # developer''s workstation adapter: mysql encoding: utf8 database: project_development host: localhost username: project password: pass ---------- migrate.rb ---------- require "rubygems" gem "activerecord" require "active_record" if ARGV[0] =~ /VERSION=\d+/ version = ARGV[0].split(''='')[1].to_i else version = nil end @logger = Logger.new $stderr ActiveRecord::Base.logger = @logger ActiveRecord::Base.colorize_logging = false @config = YAML.load_file(File.join(File.dirname(__FILE__), ''database.yml'')) ActiveRecord::Base.establish_connection(@config["development"]) ActiveRecord::Migrator.migrate("", version) ------------------ 001_create_cows.rb ------------------ class CreateCows < ActiveRecord::Migration def self.up create_table :cows do |t| t.column :name, :string t.column :breed, :string t.column :born_on, :datetime t.column :milkable, :boolean end end def self.down end end -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 22 Jan 2009, at 18:30, Frank Kany wrote:> > Good morning, > > I''m reading the book "Pro Active Record" by Marshall, Pytel, & Yurek. > Currently stuck on chapter 3. I''m using [Ruby 1.8.6 <2007-09-24> > patchlevel 111] & [Rails 2.1.1]. > > Chapter 3 discusses migrations. In the example provided in the book, > the test scripts are created and ran outside of a Rails project. The > instructions say to create a database.yml file, migrate.rb script, & > database migration script. When ''ruby migrate.rb'' is ran from ms-dos, > it should create the schema table in my database and also create the > cows table described in the migration script. > > Here''s my issue, only the ''schema_migrations'' table is created in the > database. The cows table described in the migration isn''t created in > the database. > > Please review the source below and let me know if you see anything out > of place. If you have time, try running the scripts yourself to see > if > you have better results. >Looks like the migration code has changed a little.> ActiveRecord::Migrator.migrate(".", version) >should work better. Fred --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thank you Frederick. I wish I was still running these scripts outside of a RoR project. I gave up and created a dummy RoR app just so that I could do ''rake db:migrate''. Frederick Cheung wrote:> On 22 Jan 2009, at 18:30, Frank Kany wrote: > >> database migration script. When ''ruby migrate.rb'' is ran from ms-dos, >> you have better results. >> > Looks like the migration code has changed a little. >> ActiveRecord::Migrator.migrate(".", version) >> > should work better. > > Fred-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---