J.R.
J.R.

Reputation: 6049

Skip Current Migrations but Apply Future Ones

QUESTION: Is there any way I can avoid running current migrations on a remote database already configured correctly, while ALSO being allowed to apply future migrations to it?

Context:

I have an existing rails app with plenty of migrations, that, up until now, has been using a local postgres database. A remote postgres database which SHOULD mostly match up to the structure of my local database exists.

When I try to connect to it, I get a "pending migrations" error. Attempting to run my migrations gets errors about tables already existing.

I want to skip all current migrations, but UNLIKE a lot of similar questions I'm seeing, I want to make sure my future migrations will work on this remote database.

Edit:

I followed this answer:

Rails 4 how to ignore pending migrations

And inserted my own current scheme version number into the remove database's schema_migrations table. But the pending migration remains.

I can confirm trying to run the migration gets me an error of a table already existing. This table is the FIRST migration past the remote databases previously most recent version in the schema table. It appears to be ignoring my inserted current most recent version.

Upvotes: 1

Views: 86

Answers (1)

Vasfed
Vasfed

Reputation: 18444

You have to add all migration version numbers that you want to ignore to schema_migrations

Other technique that may be also applicable - migration squashing with something like squasher or manually. Point is in combining all old migrations that are not to be rolled back into one.

Upvotes: 2

Related Questions