Search code examples
mysqlruby-on-railsrubymigrationrollback

Rails 4.2 migration error but no rollback


I have a migration with many remove_column.

I start it, but there is an error :

-- remove_column(:responses, :text_fr)
-> 0.5544s
-- remove_column(:responses, :text_en)
-> 0.2906s
-- remove_column(:topics, :text_fr)
rake aborted!
StandardError: An error has occurred, all later migrations canceled:
Mysql2::Error: Can't DROP 'text_fr'; check that column/key exists

It's my fault because I don't give the good name of column.

But my problem is : there is no automatic rollback !

I have fix the name of column in migration file, but now it's not working because text_fr don't exist in responses table...

I remember before, when an error occur, there was a rollback as if migration had not occurred...

So how enable auto-rollback of migrations?

I'm using mysql2 gem.


Solution

  • Since MySQL does not support transaction, implement up and down methods for your migrations.