views:

509

answers:

2

I'm trying to run rake test:units and I keep getting this:

Mysql::Error: Duplicate entry '2147483647' for key 1: INSERT INTO `ts_schema_migrations` (version) VALUES ('20081008010000')

The "ts_" is there because I have ActiveRecord::Base.table_name_prefix set. I'm confused because there is no value '20081008010000' already in the table, and there is no migration with the value '2147483647' (though the value does appear in the table).

In Rails' schema_statments.rb, there is the following:

def initialize_schema_migrations_table
  sm_table = ActiveRecord::Migrator.schema_migrations_table_name

    unless tables.detect { |t| t == sm_table }
      create_table(sm_table, :id => false) do |schema_migrations_table|
        schema_migrations_table.column :version, :string, :null => false
      end
      ...

In my development database, ts_schema_migrations.version is a VARCHAR. In test, though it's an INTEGER. I've dropped the tables and re-run the migrations (and/or a rake db:schema:load RAILS_ENV=test) several times. No changes.

Is something wrong with my MySQL adapter?

+1  A: 

It looks as though your test schema is Rails 1.x somehow, whereas development is Rails 2. Perhaps you could set RAILS_ENV to test and run rake db:reset

Mike Woodhouse
+1  A: 

It looks like you skipped some steps when upgrading from Rails 1.x to 2.0.

Go through and read the upgrade notes:

http://www.slashdotdash.net/2007/12/03/rails-2-upgrade-notes/

And the release notes:

http://weblog.rubyonrails.org/2007/12/7/rails-2-0-it-s-done

They will tell you all the steps you need to follow. Particularly regenerating all the scripts and migrating your database to the new system of database migrations by timestamp instead of incrementing migration id.

rabble
I never used Rails 1.x on this computer, on this database, or with this project. I'm confused.
James A. Rosen