-
-
Notifications
You must be signed in to change notification settings - Fork 58
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
Add option to run pg_dump
into migrations/schema.sql
on commit by default
#110
Comments
I did consider it, but I’m not sure that pg_dump is the optimal experience for all users. Some people have other equally valid strategies (for example one person has set up a series of pg_dump scripts that dump different schemas and different resources into different files), so I don’t think enforcing a particular flow (e.g. single pg_dump) is best. Further, people may want to only dump schemas that graphile migrate is used with; I know migrate users that have per-tenant custom schemas that aren’t managed via migrations that they don’t want dumped via pg_dump, so they must pass custom options. Building it in seems like decreased flexibility and greater maintenance burden; though I do think it may be worth enabling (rather than commenting) in the default gmrc. |
Right – that's why it should be an option! And some of these enhancements users have developed for themselves also sound useful to bake in, if possible. For example, a single In sum:
The reason I think this is important is that if I want to convince a team to use graphile-migrate, it shouldn't feel like core elements of the workflow are bolted-on by me, but baked in to the tool. Plus, maintaining shell scripts (embedded into a string or otherwise) is no fun 😅 |
I'd also be interested in being able to edit the pg_dump and having a tool (not necessarily this one) generate an editable migration file. This might be accomplishable by calling into pgadmin's code for their "schema diff" feature: djrobstep/migra#148 This might help get closer to the more declarative workflows developers tend to like |
It would be interesting if during development I could just edit the database using a GUI like TablePlus, have something like migra/pgadmin4 cli diff running in watch mode watching the dev database and the shadow database and generate sql migration ddl into current.sql or whatever for every change. It would also be nice if this same process was watching pg_dump:ed files schema.sql and schema.current.sql or something so that one could choose to just change the dump of the schema instead of usinga GUI for it. Alternatively, have something watch for changes to the database schema and dump the updated structure to schema.current.sql, then have something like pgadmin2 cli diff watcing the 2 schema files to generate the migration sql. Then in the end, you would check on the auto generated sql for the migration and commit it once you're happy. For some scenarios, you would just handwrite the migration sql yourself. |
These are all great ideas, and why this functionality is not baked in. Had we baked it in, someone would think “this is the way” and there’d be less space for innovation. Graphile Migrate is only the foundation of what is to come, but what is to come has not yet fully formed. One day it will govern an excellent flow that will be comfortable and productive, but for now it’s up to users to figure out what works best for them. I’m also perfectly happy (in fact I frequently encourage!) for people to use other migration frameworks; I built this tool primarily for myself. |
Feature description
The README currently recommends doing this yourself, and provides a straightforward example, but IMO this should be built-in and ideally enabled by default once proven out.
My thinking is that reviewing the final
schema.sql
should be core to the workflow of usinggraphile-migrate
– this is an opinionated tool, and it should be okay to enforce this opinion (especially because some of its other opinions don't work so well without it, like the fact that you can accidentally leave arnd()
function lying around). I don't think a tool like this should be used without dumping and reviewing the schema.sql on every commit.Ideally, any issues people have with this workflow should also be reported and fixes shared, rather than worked around in each user's bash scripts.
Disclaimer that I am a prospective user, not an active user – this is more a suggestion than a request.
Motivating example
Breaking changes
Supporting development
I [tick all that apply]:
The text was updated successfully, but these errors were encountered: