-
Notifications
You must be signed in to change notification settings - Fork 2.8k
add an api to dump postgres schema (close #1939) #1967
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
Conversation
|
Deploy preview for hasura-docs ready! Built with commit ea02b56 |
|
Review app for commit cd7ef59 deployed to Heroku: https://hge-ci-pull-1967.herokuapp.com |
|
@shahidhk Can you add |
|
Review app for commit c70d9f9 deployed to Heroku: https://hge-ci-pull-1967.herokuapp.com |
|
Review app for commit dff389c deployed to Heroku: https://hge-ci-pull-1967.herokuapp.com |
rikinsk-zz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docs approved
rikinsk-zz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docs approved
|
Review app for commit fe547c9 deployed to Heroku: https://hge-ci-pull-1967.herokuapp.com |
| -> Q.ConnInfo | ||
| -> m BL.ByteString | ||
| execPGDump b ci = do | ||
| output <- liftIO $ runScript dbUrl opts clean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
runScript is prone to IO exception when the filename is not found in disk or maybe other reasons. Use try to catch IO exception explicitly.
|
@shahidhk Maybe we need some docs change here: https://docs.hasura.io/1.0/graphql/manual/migrations/existing-database.html#step-3-initialize-the-migrations-as-per-your-current-state |
|
Review app for commit 8b44a52 deployed to Heroku: https://hge-ci-pull-1967.herokuapp.com |
rakeshkky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
server LGTM
|
Review app for commit ea02b56 deployed to Heroku: https://hge-ci-pull-1967.herokuapp.com |
|
Review app https://hge-ci-pull-1967.herokuapp.com is deleted |
Description
This PR adds a new admin-only API for getting schema dumps from the connected Postgres instance.
response:
If there is an error, the response will be JSON with the right error code and error messages.
Since this is an API executing a shell script on the server, an option is provided to enable/disable the API. By default, the API is enabled. To disable, use the
--enabled-apisby excludingpgdumpout of the default valuegraphql,metadata,pgdump.Affected components
Related Issues
close #1939
Solution and Design
A new admin-only POST endpoint which takes
schemaas a JSON key. The handler executes a shell script (https://github.com/shahidhk/graphql-engine/blob/pg-dump-on-server/server/src-rsr/run_pg_dump.sh) which executespg_dumpand writes the output to file. This file is then read and sent to the client in the response body.The
clean: trueargument will clean the output to remove:CREATE SCHEMA public.COMMENT ON SCHMEA public is 'standard public schema';--) and empty newlines.Steps to test and verify
curl -d'{"opts": ["-O", "-x", "--schema", "public", "--schema-only"],"clean_output": true}' http://localhost:8080/v1alpha1/pg_dumpLimitations, known bugs & workarounds
Thepg_dumpbinary is not yet included in the docker image, the docker image will not work.Tests are pending.NA