None of these answers quite fit the problem i had as the migration i wanted to delete was missing:
I had created and run a migration in some other branch, which was then discarded. The problem is when a migration is run, rails adds the version into a schema_migrations
table in the database. So even if it isn't listed in your db structure or schema, rails looks for it.
You can reveal these orphaned migrations by running:
rails db:migrate:status
Note the versions of the missing migrations and head into the db console:
rails dbconsole
Now remove the versions from the migration table manually:
delete from schema_migrations where version='<version>';
You should now be good.