Skip to content

Truncate table tool #899

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

Closed
kevinburke1 opened this issue Feb 18, 2021 · 3 comments
Closed

Truncate table tool #899

kevinburke1 opened this issue Feb 18, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@kevinburke1
Copy link
Contributor

One thing I frequently want/need to do is truncate a test database. Generally this is something along the lines of

BEGIN 
SET CONSTRAINTS ALL DEFERRED
DELETE FROM <>;
DELETE FROM <>;
COMMIT;

It would be nice to be able to get a list of tables out in order to run this query.

(My initial thought was sqlc should build a dependency graph to delete the tables in the right order and then realized we don't need to do that because you can defer constraint enforcement to the end.)

@kevinburke1
Copy link
Contributor Author

Related, I am needing to add info about the pg_tables or information_schema tables in order to get sqlc to compile a query to list all of the tables.

@kevinburke1
Copy link
Contributor Author

Ahhh, right, I do need the dependency graph because foreign keys are not deferrable by default so I need to go back and make them all deferrable or delete the tables in the "correct" order which in theory sqlc could infer.

@kyleconroy kyleconroy added the enhancement New feature or request label Mar 20, 2021
@kyleconroy
Copy link
Collaborator

I'm working on adding support for all the pg_* tables from the system catalog here #1171.

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

2 participants