#1262 ✓not-applicable
Robert Rouse

Auto migrate fails in current master

Reported by Robert Rouse | May 8th, 2010 @ 11:42 AM

When running rake db:automigrate, I get the following error. It was working fine last weekend I believe.

Robert-Rouses-iMac:project robertrouse$ rake db:automigrate --trace
(in /Users/robertrouse/code/projects/webapps/work/project)
** Invoke db:automigrate (first_time)
** Invoke db:load_models (first_time)
** Invoke environment (first_time)
** Execute environment
[datamapper] Setting up the "development" environment:
[datamapper] Setting up :default repository: 'mydatabase' on mysql
** Execute db:load_models
** Execute db:automigrate
rake aborted!
Can't create table 'mydatabase.#sql-282c_22' (errno: 150)
/Users/robertrouse/.rvm/gems/ruby-head@rails3/bundler/gems/dm-do-adapter-1d52cea8904d4da687c2fddabd5bf999c94cd21e-master/lib/dm-do-adapter/adapter.rb:63:in `execute_non_query'
/Users/robertrouse/.rvm/gems/ruby-head@rails3/bundler/gems/dm-do-adapter-1d52cea8904d4da687c2fddabd5bf999c94cd21e-master/lib/dm-do-adapter/adapter.rb:63:in `block in execute'
/Users/robertrouse/.rvm/gems/ruby-head@rails3/bundler/gems/dm-do-adapter-1d52cea8904d4da687c2fddabd5bf999c94cd21e-master/lib/dm-do-adapter/adapter.rb:260:in `with_connection'
/Users/robertrouse/.rvm/gems/ruby-head@rails3/bundler/gems/dm-do-adapter-1d52cea8904d4da687c2fddabd5bf999c94cd21e-master/lib/dm-do-adapter/adapter.rb:61:in `execute'
/Users/robertrouse/.rvm/gems/ruby-head@rails3/bundler/gems/dm-constraints-13024c6b2e30ceb19ac2e8d9a7d45d79810f2223-master/lib/dm-constraints/adapters/dm-do-adapter.rb:64:in `create_relationship_constraint'
/Users/robertrouse/.rvm/gems/ruby-head@rails3/bundler/gems/dm-constraints-13024c6b2e30ceb19ac2e8d9a7d45d79810f2223-master/lib/dm-constraints/migrations.rb:51:in `block in execute_each_relationship'
/Users/robertrouse/.rvm/gems/ruby-head@rails3/bundler/gems/dm-constraints-13024c6b2e30ceb19ac2e8d9a7d45d79810f2223-master/lib/dm-constraints/migrations.rb:50:in `each_value'
/Users/robertrouse/.rvm/gems/ruby-head@rails3/bundler/gems/dm-constraints-13024c6b2e30ceb19ac2e8d9a7d45d79810f2223-master/lib/dm-constraints/migrations.rb:50:in `execute_each_relationship'
/Users/robertrouse/.rvm/gems/ruby-head@rails3/bundler/gems/dm-constraints-13024c6b2e30ceb19ac2e8d9a7d45d79810f2223-master/lib/dm-constraints/migrations.rb:43:in `auto_migrate_up_constraints!'
/Users/robertrouse/.rvm/gems/ruby-head@rails3/bundler/gems/dm-migrations-10e2a03514bd272776b61444593ff4b4fe608269-master/lib/dm-migrations/auto_migration.rb:45:in `block in repository_execute'
/Users/robertrouse/.rvm/gems/ruby-head@rails3/bundler/gems/dm-core-37b4bd22b9e3842977cf83d32baba459607e900a-master/lib/dm-core/model/descendant_set.rb:33:in `block in each'
/Users/robertrouse/.rvm/gems/ruby-head@rails3/bundler/gems/dm-core-37b4bd22b9e3842977cf83d32baba459607e900a-master/lib/dm-core/model/descendant_set.rb:33:in `each'
/Users/robertrouse/.rvm/gems/ruby-head@rails3/bundler/gems/dm-core-37b4bd22b9e3842977cf83d32baba459607e900a-master/lib/dm-core/model/descendant_set.rb:33:in `each'
/Users/robertrouse/.rvm/gems/ruby-head@rails3/bundler/gems/dm-migrations-10e2a03514bd272776b61444593ff4b4fe608269-master/lib/dm-migrations/auto_migration.rb:44:in `repository_execute'
/Users/robertrouse/.rvm/gems/ruby-head@rails3/bundler/gems/dm-constraints-13024c6b2e30ceb19ac2e8d9a7d45d79810f2223-master/lib/dm-constraints/migrations.rb:12:in `auto_migrate!'
/Users/robertrouse/.rvm/gems/ruby-head@rails3/bundler/gems/dm-rails-6d789ab541218bf52f1038ecd3856026704f4c3b-master/lib/dm-rails/railties/database.rake:52:in `block (3 levels) in <top (required)>'
/Users/robertrouse/.rvm/gems/ruby-head@rails3/bundler/gems/dm-rails-6d789ab541218bf52f1038ecd3856026704f4c3b-master/lib/dm-rails/railties/database.rake:51:in `each'
/Users/robertrouse/.rvm/gems/ruby-head@rails3/bundler/gems/dm-rails-6d789ab541218bf52f1038ecd3856026704f4c3b-master/lib/dm-rails/railties/database.rake:51:in `block (2 levels) in <top (required)>'
/Users/robertrouse/.rvm/gems/ruby-head@rails3/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/Users/robertrouse/.rvm/gems/ruby-head@rails3/gems/rake-0.8.7/lib/rake.rb:636:in `block in execute'
/Users/robertrouse/.rvm/gems/ruby-head@rails3/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/Users/robertrouse/.rvm/gems/ruby-head@rails3/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/Users/robertrouse/.rvm/gems/ruby-head@rails3/gems/rake-0.8.7/lib/rake.rb:597:in `block in invoke_with_call_chain'
/Users/robertrouse/.rvm/rubies/ruby-head/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/robertrouse/.rvm/gems/ruby-head@rails3/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Users/robertrouse/.rvm/gems/ruby-head@rails3/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/Users/robertrouse/.rvm/gems/ruby-head@rails3/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/Users/robertrouse/.rvm/gems/ruby-head@rails3/gems/rake-0.8.7/lib/rake.rb:2029:in `block (2 levels) in top_level'
/Users/robertrouse/.rvm/gems/ruby-head@rails3/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/Users/robertrouse/.rvm/gems/ruby-head@rails3/gems/rake-0.8.7/lib/rake.rb:2029:in `block in top_level'
/Users/robertrouse/.rvm/gems/ruby-head@rails3/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Users/robertrouse/.rvm/gems/ruby-head@rails3/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/Users/robertrouse/.rvm/gems/ruby-head@rails3/gems/rake-0.8.7/lib/rake.rb:2001:in `block in run'
/Users/robertrouse/.rvm/gems/ruby-head@rails3/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Users/robertrouse/.rvm/gems/ruby-head@rails3/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/Users/robertrouse/.rvm/gems/ruby-head@rails3/gems/rake-0.8.7/bin/rake:31:in `<top (required)>'
/Users/robertrouse/.rvm/gems/ruby-head@rails3/bin/rake:19:in `load'
/Users/robertrouse/.rvm/gems/ruby-head@rails3/bin/rake:19:in `<main>'

Comments and changes to this ticket

  • Robert Rouse

    Robert Rouse May 8th, 2010 @ 11:44 AM

    • Tag set to 0.10.3
  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) May 10th, 2010 @ 11:37 AM

    • State changed from “new” to “not-applicable”

    On edge, you need to require dm-migrations before DataMapper.auto_migrate! is available now.

  • Robert Rouse

    Robert Rouse May 10th, 2010 @ 09:15 PM

    It is required in my GemFile and also is referenced in the error stack trace I posted.

    Is this a Bundler require order issue or something else?

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) May 10th, 2010 @ 11:19 PM

    Hmm. As a test, can you try dropping the database and recreating it?

    What I think is happening is there's a table that references the previous table of the same name, and MySQL is exploding due to some difference in the table's schema.

    There are many reasons this could happen, such as removing/renaming models, and then auto-migrating (DM only knows about the tables you map to it, so the old table created prior to the renaming will not get cleaned up by it -- for safety it has to ignore anything unmapped).

    Since you only want to use auto-migrate when developing locally, whenever the DB gets in an invalid state due changes in the mapping, I would recommend recreating the DB first before investigating further.

    Please let me know how this works out for you.

  • Robert Rouse

    Robert Rouse May 10th, 2010 @ 11:47 PM

    I dropped it and tried again. No change.

    The bit after the database name changes slightly each time I try to run it.

    rake db:autoupgrade works just fine.

  • Robert Rouse

    Robert Rouse May 11th, 2010 @ 12:26 AM

    So after talking to dkubb in IRC (THANKS!), we figured out it was my fault. I had explicitly defined my FKs without realizing that DataMapper takes care of it for me.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket

Tags

Pages