I have already destroyed a scaffold "Location" and its table but I forgot to rollback/remove a migrated column "slug and its index" before destroying the "Location" table . How can I remove the migration for slug and index.
Migrated slug column
class AddSlugToLocations < ActiveRecord::Migration[5.1]
def change
add_column :locations, :slug, :string
add_index :locations, :slug
end
end
Your help will be really appreciated, heroku won't deploy because of this issue
I have tried ActiveRecord::SchemaMigration.where(version=20180412191332).delete_all
but no luck
Also tried rake db:migrate:down VERSION=20180412191332
but giving error: No indexes found on locations with the options provided.
You manually deleted a table from your application's database. Now running migrations raises an error because one of the migrations is trying to alter the table that doesn't exist anymore.
Just delete the failing migration from your codebase and redeploy your application.
From your question, I assume that the migration with the number 20180412191332
causes the issue. Find that migration file in db/migrate/20180412191332_...rb
, delete it and redeploy to Heroku.
If you're having trouble deleting the migration from your, schema, you could try to do it in the SQL console :
USE mytable/dev;
DELETE FROM schema_migrations WHERE version = '20180412191332';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With