This project is archived and is in readonly mode.
Migration error with rails 2.1 and drop_table -- still looking for schema_info
-
axs89
I'm also seeing the same problem - Rails 2.1
-
Ernie Miller
I can't duplicate this. Copied your specific migration to a file, got the following with rake db:migrate:
C:\Users\Neo\blah>rake db:migrate
(in C:/Users/Neo/blah)
== 20080701012651 TestMigration: migrating ====================================
-- create_table(:blah)
-> 0.0030s
== 20080701012651 TestMigration: migrated (0.0040s) ===========================
C:\Users\Neo\blah>rake db:migrate VERSION=0
(in C:/Users/Neo/blah)
== 20080701012651 TestMigration: reverting ====================================
-- drop_table(:blah)
-> 0.0040s
== 20080701012651 TestMigration: reverted (0.0040s) ===========================
-
barunio
hm, strange. well i just tried it again and still get that error with the exact code i've provided. are you trying this from a new rails project? (i wonder if perhaps the error only occurs when dealing with an older project that was originally created pre-2.1)
-
Ernie Miller
I did try with a new rails project. From glancing through the migration code, it looked to me like the schema_info table undergoes a one-time conversion to schema_migrations in activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb, in the initialize_schema_migrations_table method, which gets called by Migrator.initialize. Right near the very top of the method, it has a condition:
unless tables.detect { |t| t == sm_table }
which should stop the entire method from running once that table has been created.
-
David Mitchell
I have a project that used 2.0.1 and can confirm that this error is not an isolated incident. It only happens when trying to revert migrations. I dropped the entire database, migrated and then reverted and it died while still doing the first migration back.
-
David Mitchell
Here's the stack trace for the error:
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
== 41 CreateMilestones: reverting =============================================
-- drop_table(:milestones)
rake aborted!
Mysql::Error: Table 'nms_dev.schema_info' doesn't exist: select version from schema_info limit 1
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/abstract_adapter.rb:147:in `log'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/mysql_adapter.rb:299:in `execute'
C:/dev/globaltrack/vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/mysql_adapter.rb:59:in `reverse_foreign_keys'
C:/dev/globaltrack/vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/abstract_adapter.rb:27:in `drop_table'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/mysql_adapter.rb:408:in `drop_table'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/migration.rb:330:in `send'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/migration.rb:330:in `method_missing'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/migration.rb:310:in `say_with_time'
c:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/migration.rb:310:in `say_with_time'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/migration.rb:326:in `method_missing'
./db/migrate//041_create_milestones.rb:15:in `down_without_benchmarks'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/migration.rb:264:in `send'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/migration.rb:264:in `migrate'
c:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/migration.rb:264:in `migrate'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/migration.rb:430:in `migrate'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/migration.rb:420:in `each'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/migration.rb:420:in `migrate'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/migration.rb:361:in `down'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/migration.rb:341:in `migrate'
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/tasks/databases.rake:99
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `call'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `execute'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `each'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `execute'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:508:in `invoke_with_call_chain'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `synchronize'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `invoke_with_call_chain'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:494:in `invoke'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1931:in `invoke_task'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `each'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in `standard_exception_handling'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1903:in `top_level'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1881:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in `standard_exception_handling'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1878:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/bin/rake:31
C:/ruby/bin/rake:16:in `load'
C:/ruby/bin/rake:16
-
David Mitchell
I took a closer look at the stack trace, updated all my plugins and it looks like my problem was related to an older version of the redhillonrails plugins. Hope that helps somebody who was in the same situation.
-
josh
- State changed from new to stale
- Tag changed from 2.1, bug, migrations to 2.1, bug, migrations