You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At my company when we revert a change we want to just make a new migration that does the inverse of what a reverted migration does. For migrations with a down() migration, this is easy - just call it in the up() migration.
But for migrations where it is inferred, it is not obvious how you would call the automatic down() migration for a given up() migration. But! Internally this library's enableReverseMode() function would do the trick, just call it first before calling the up() migration.
But, the TypeScript interface doesn't say it exists, nor is it mentioned in the docs. But I'm pretty sure this should generally work.
So my suggestion is to not hide this and actually make it be a documented part of this library. Even further, it would potentially make sense to even have a CLI command to generate a "revert" migration for a given migration.
The text was updated successfully, but these errors were encountered:
@osdiab You can consider using @lorefnon/ts-pg-migrate where I have exposed this. I maintain that fork because I needed some features from a few PRs here that haven't received any attention in many months.
It is backward compatible - nothing other than package name needs to be changed.
Internally, this library appears to use an
enableReverseMode()
function to reverse the commands of a migration when inferring adown()
migration.At my company when we revert a change we want to just make a new migration that does the inverse of what a reverted migration does. For migrations with a
down()
migration, this is easy - just call it in theup()
migration.But for migrations where it is inferred, it is not obvious how you would call the automatic
down()
migration for a givenup()
migration. But! Internally this library'senableReverseMode()
function would do the trick, just call it first before calling theup()
migration.But, the TypeScript interface doesn't say it exists, nor is it mentioned in the docs. But I'm pretty sure this should generally work.
So my suggestion is to not hide this and actually make it be a documented part of this library. Even further, it would potentially make sense to even have a CLI command to generate a "revert" migration for a given migration.
The text was updated successfully, but these errors were encountered: