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

Checkpoint tries to truncate internal Postgres tables #70

Closed
tersers opened this issue Oct 8, 2020 · 4 comments · Fixed by #72
Closed

Checkpoint tries to truncate internal Postgres tables #70

tersers opened this issue Oct 8, 2020 · 4 comments · Fixed by #72
Milestone

Comments

@tersers
Copy link
Contributor

tersers commented Oct 8, 2020

Hello! Thanks for writing this tool, having written a bunch of DB-related tests in the past I know how difficult it is to set up and tear down the tables and this makes things so much easier.

I am using Respawn version 3.3.0 with the Postgres adapter.

I'm running into a problem where the checkpoint tries to delete some tables internal to Postgres. The relevant SQL lines are as follows:

TRUNCATE TABLE "information_schema"."sql_sizing_profiles",
               "information_schema"."sql_sizing",
               "information_schema"."sql_languages",
               "information_schema"."sql_implementation_info",
               "information_schema"."sql_features",
               "information_schema"."sql_packages",
               "pg_catalog"."pg_subscription_rel",
               "pg_catalog"."pg_publication_rel",
               "pg_catalog"."pg_publication",
               "pg_catalog"."pg_sequence",
               "pg_catalog"."pg_transform",
               "pg_catalog"."pg_range",
               "pg_catalog"."pg_partitioned_table",
               "pg_catalog"."pg_collation",
               "pg_catalog"."pg_shseclabel",
               "pg_catalog"."pg_seclabel",
               "pg_catalog"."pg_init_privs",
               "pg_catalog"."pg_default_acl",
               "pg_catalog"."pg_replication_origin",
               "pg_catalog"."pg_policy",
               "pg_catalog"."pg_foreign_table",
               "pg_catalog"."pg_foreign_data_wrapper",
               "pg_catalog"."pg_extension",
               "pg_catalog"."pg_ts_template",
               "pg_catalog"."pg_ts_parser",
               "pg_catalog"."pg_ts_dict",
               "pg_catalog"."pg_ts_config_map",
               "pg_catalog"."pg_ts_config",
               "pg_catalog"."pg_shdescription",
               "pg_catalog"."pg_shdepend",
               "pg_catalog"."pg_auth_members",
               "pg_catalog"."pg_pltemplate",
               "pg_catalog"."pg_tablespace",
               "pg_catalog"."pg_db_role_setting",
               "pg_catalog"."pg_database",
               "pg_catalog"."pg_depend",
               "pg_catalog"."pg_conversion",
               "pg_catalog"."pg_namespace",
               "pg_catalog"."pg_enum",
               "pg_catalog"."pg_cast",
               "pg_catalog"."pg_description",
               "pg_catalog"."pg_event_trigger",
               "pg_catalog"."pg_trigger",
               "pg_catalog"."pg_rewrite",
               "pg_catalog"."pg_statistic_ext",
               "pg_catalog"."pg_aggregate",
               "pg_catalog"."pg_largeobject_metadata",
               "pg_catalog"."pg_language",
               "pg_catalog"."pg_amproc",
               "pg_catalog"."pg_amop",
               "pg_catalog"."pg_am",
               "pg_catalog"."pg_opclass",
               "pg_catalog"."pg_opfamily",
               "pg_catalog"."pg_operator",
               "pg_catalog"."pg_index",
               "pg_catalog"."pg_inherits",
               "pg_catalog"."pg_constraint",
               "pg_catalog"."pg_attrdef",
               "pg_catalog"."pg_class",
               "pg_catalog"."pg_proc",
               "pg_catalog"."pg_attribute",
               "pg_catalog"."pg_subscription",
               -- Some of my tables in the lines following --
               "pg_catalog"."pg_foreign_server",
               -- Some more of my tables  --
               "pg_catalog"."pg_type",
               -- More of my tables afterwards-- CASCADE;

My calling code:

var checkpoint = new Checkpoint
{
    DbAdapter = DbAdapter.Postgres
};

using var connection = _dbContext.Database.GetDbConnection();
await connection.OpenAsync();
await checkpoint.Reset(connection);

Is there a configuration step I missed?

Thanks!

@jbogard
Copy link
Owner

jbogard commented Oct 8, 2020

Check out the "SchemasToExclude" properties. You can then ignore pg_catalog etc

@tersers
Copy link
Contributor Author

tersers commented Oct 8, 2020

Hi @jbogard, thanks for your response! That indeed fixed the problem.

Would you be open to excluding Postgres system schemas by default? Everything I've searched indicates these tables should never be deleted so it may be reasonable for the Respawn logic to ignore anything in "pg_catalog" and "information_schema".

@jbogard
Copy link
Owner

jbogard commented Oct 8, 2020

Not at all! I'm not a PG user so it's all been driven by PRs.

@tersers
Copy link
Contributor Author

tersers commented Oct 8, 2020

Okay, I'll work on that! Thanks for your help and openness!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants