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

Remove cluster hooks in favour of pg_dumpall -g #48

Open
JAForbes opened this issue May 31, 2024 · 1 comment
Open

Remove cluster hooks in favour of pg_dumpall -g #48

JAForbes opened this issue May 31, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@JAForbes
Copy link
Owner

We've got an always hook that runs always, but after the transaction. But maybe we should rename it to post and have a pre hook. Both hooks would always run and could be used to create roles using a declarative util.

I want to remove the cluster hooks concept (see #46). Hostname isn't a good property to rely on to detect change.

We also tend to configure our local env so the production db url is the same as the local db url within a docker container. So relying on the hostname in the db url isn't great either.

I also considered having a top level export for roles, but we would need to diff them to see if properties change and that mixes metaphors because pgmg is declarative, so having a single declarative hook feels like it could cause confusion and lead to surprise if it does or doesn't respond to change.

@JAForbes JAForbes added the enhancement New feature or request label May 31, 2024
@JAForbes
Copy link
Owner Author

I've been playing with a new revision that has pre/post and no cluster hooks, but I think the use case is a little flaky. Yeah you could create roles (with the new util) in pre and do grants in post, then you won't need do use pg_dumpall -g to seed roles.

But it requires too much knowledge of the execution of pgmg and its awkward to define grants / roles in these separate hooks that always run.

I think restoring a local prod snapshot is something pgmg shouldn't do because I've found from project to project we tweak the config of how local prod works. If pgmg has opinions about restoring local backups then it becomes inflexible for end users.

But the primary reason pgmg exists is for Harth to have a simple migration process across projects, so if we bake in a restore command then it will be beneficial to us and we can remove the reliance on pre/post for every single migration script. If we can assume roles/grants are managed by restore then everything becomes simpler for a local dev workflow.

So now I think we still do drop cluster hooks / hostname diffing. But we assume roles/grants are already present. In a later release we can add a restore command but for now we just document the assumptions about the end users restore process.

I think we still keep pre/post but we do not rely on them for normal migrations, they are there for special edge cases for the users benefit.

@JAForbes JAForbes changed the title Remove cluster hooks in favour of generic pre hook Remove cluster hooks in favour of pg_dumpall -g Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant