I'm getting this error after trying to update a gem (mailboxer) and removing it.
Mysql2::Error: Table 'conversations' already exists: CREATE TABLE conversations
(id
int(11) DEFAULT NULL auto_increment PRIMARY KEY, subject
varchar(255) DEFAULT '', created_at
datetime NOT NULL, updated_at
datetime NOT NULL)
I tried:
- Bundle exec rake db:migrate rollback then rake db:migrate
- Bundle exec rake db:migrate v= xxxxxxxx then rake db:migrate
- getting rid of the migration files (that worked but I don't like the though of just getting rid of code)
I do not want to loose my data and drop the tables. Any thoughts?
Update:
Rake db:migrate:status
up 20140526010413 Adduserfollowme to users
up 20140703193119 Add vote weight to votes
up 20140713211140 Add partime to user
up 20140716024440 Add devise to admin users
up 20140716024510 Create active admin comments
up 20140727042518 ********** NO FILE **********
up 20140727051902 Add slug to activities
down 20140728031732 Create mailboxer.mailboxer engine
down 20140728031733 Add notified object.mailboxer engine
down 20140728031734 Add notification code.mailboxer engine
down 20140728031735 Add attachments.mailboxer engine
down 20140728031736 Rename receipts read.mailboxer engine
down 20140728031737 Add global notification support.mailboxer engine
rake db:rollback
== AddSlugToActivities: reverting ============================================
-- remove_index("activities", {:column=>:slug})
-> 0.0215s
-- remove_column("activities", :slug)
-> 0.0342s
== AddSlugToActivities: reverted (0.0559s) ===================================
Rake db:migrate
== AddSlugToActivities: migrating ============================================
-- add_column(:activities, :slug, :string)
-> 0.0266s
-- add_index(:activities, :slug)
-> 0.0104s
== AddSlugToActivities: migrated (0.0373s) ===================================
== CreateMailboxer: migrating ================================================
-- create_table(:conversations)
rake aborted!
StandardError: An error has occurred, all later migrations canceled:
Mysql2::Error: Table 'conversations' already exists: CREATE TABLE `conversations` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `subject` varchar(255) DEFAULT '', `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB/home/bill/apps/woomatch/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:243:in `query'
/home/bill/apps/woomatch/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:243:in `block in execute'
/home/bill/apps/woomatch/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
/home/bill/apps/woomatch/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/bill/apps/woomatch/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
/home/bill/apps/woomatch/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:243:in `execute'
/home/bill/apps/woomatch/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/connection_adapters/mysql2_adapter.rb:211:in `execute'
/home/bill/apps/woomatch/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract/schema_statements.rb:170:in `create_table'
/home/bill/apps/woomatch/shared/bundle/ruby/1.9.1/gems/foreigner-1.6.1/lib/foreigner/connection_adapters/abstract/schema_statements.rb:14:in `create_table'
/home/bill/apps/woomatch/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:432:in `create_table'
/home/bill/apps/woomatch/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/migration.rb:466:in `block in method_missing'
/home/bill/apps/woomatch/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/migration.rb:438:in `block in say_with_time'
/home/bill/apps/woomatch/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/migration.rb:438:in `say_with_time'
/home/bill/apps/woomatch/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/migration.rb:458:in `method_missing'
/home/bill/apps/woomatch/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/migration.rb:334:in `method_missing'
/home/bill/apps/woomatch/releases/20140728100705/db/migrate/20140728031732_create_mailboxer.mailboxer_engine.rb:6:in `up'
/home/bill/apps/woomatch/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/migration.rb:370:in `up'
/home/bill/apps/woomatch/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/migration.rb:410:in `block (2 levels) in migrate'
/home/bill/apps/woomatch/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/migration.rb:410:in `block in migrate'
/home/bill/apps/woomatch/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract/connection_pool.rb:129:in `with_connection'
/home/bill/apps/woomatch/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/migration.rb:389:in `migrate'
/home/bill/apps/woomatch/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/migration.rb:528:in `migrate'
/home/bill/apps/woomatch/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/migration.rb:720:in `block (2 levels) in migrate'
/home/bill/apps/woomatch/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/migration.rb:777:in `call'
/home/bill/apps/woomatch/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/migration.rb:777:in `ddl_transaction'
/home/bill/apps/woomatch/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/migration.rb:719:in `block in migrate'
/home/bill/apps/woomatch/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/migration.rb:700:in `each'
/home/bill/apps/woomatch/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/migration.rb:700:in `migrate'
/home/bill/apps/woomatch/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/migration.rb:570:in `up'
/home/bill/apps/woomatch/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/migration.rb:551:in `migrate'
/home/bill/apps/woomatch/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/railties/databases.rake:179:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:migrate
What should I do next?
There is no
rake db:migrate rollback
, onlyrake db:rollback
Tryrake db:migrate:status
, then userake db:rollback
to make unwanted migrations to be down.Sometimes when 'something went wrong' and you migrate-rollback a lot, it is necessary to comment up some lines, make migrate\rollback and incomment them again.
If it doesnt work, try show code of migrations that fail