Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reveal and document pgm.enableReverseMode() #955

Open
osdiab opened this issue Feb 15, 2024 · 3 comments
Open

Reveal and document pgm.enableReverseMode() #955

osdiab opened this issue Feb 15, 2024 · 3 comments
Labels
s: pending triage Pending Triage

Comments

@osdiab
Copy link
Collaborator

osdiab commented Feb 15, 2024

Internally, this library appears to use an enableReverseMode() function to reverse the commands of a migration when inferring a down() 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 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.

@lorefnon
Copy link

@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.

@Shinigami92
Copy link
Collaborator

@lorefnon do you still have the fork? Would you like to work with me together on node-pg-migrate? I got repo-admin rights (not org-admin).


Beside that, I need to have a look into what enableReverseMode is actually doing, and/or if this is outdated.

@Shinigami92 Shinigami92 added the s: pending triage Pending Triage label Apr 26, 2024
@lorefnon
Copy link

Hi yeah, good to see this repo maintained once more.

I have a few minor features in my fork. I use this in production. I'll send separate PRs for them over the next few days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s: pending triage Pending Triage
Projects
None yet
Development

No branches or pull requests

3 participants