datamapper / dm-migrations

DataMapper plugin for writing and speccing migrations
http://datamapper.org/
MIT License
66 stars 42 forks source link

Explicit migrations cannot lookup DataMapper Property constants with dm-rails and Ruby 1.8.7 #34

Open postmodern opened 13 years ago

postmodern commented 13 years ago

I kept running into this bug in a dm-rails app where explicit migrations could not resolve Property constants under Ruby 1.8.7, but work as expected under 1.9.2.

Steps to Reproduce

  1. rails new dm-bug -m http://datamapper.org/templates/rails.rb
  2. Add an explicit migration:

    migration 1, :create_users do
     up do
       create_table :users do
         column :id, Serial
         column :name, String
         column :bio, Text
       end
     end
    
     down do
       drop_table :users
     end
    end
  3. rake db:migrate:up

    Expected Results

    • Ruby 1.9.2: Success
    • Ruby 1.8.7: Success

      Actual Results

    • Ruby 1.9.2: Success
    • Ruby 1.8.7:
$ rake db:migrate:up --trace
** Invoke db:migrate:up (first_time)
** Invoke db:migrate:load (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate:load
** Execute db:migrate:up
 == Performing Up Migration #1: create_users
rake aborted!
uninitialized constant Serial
./db/migrate/001_create_users.rb:4:in `(root)'
/home/hal/.rvm/gems/jruby-1.6.4/gems/dm-migrations-1.1.0/lib/dm-migrations/sql/table_creator.rb:17:in `instance_eval'
/home/hal/.rvm/gems/jruby-1.6.4/gems/dm-migrations-1.1.0/lib/dm-migrations/sql/table_creator.rb:17:in `initialize'
/home/hal/.rvm/gems/jruby-1.6.4/gems/dm-migrations-1.1.0/lib/dm-migrations/migration.rb:142:in `create_table'
./db/migrate/001_create_users.rb:3:in `(root)'

I have successfully reproduced this bug under MRI 1.8.7 and JRuby 1.6.4.