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

Issue with truncate cascade in Postgres #107

Open
ayedo opened this issue Nov 15, 2022 · 1 comment
Open

Issue with truncate cascade in Postgres #107

ayedo opened this issue Nov 15, 2022 · 1 comment

Comments

@ayedo
Copy link

ayedo commented Nov 15, 2022

Hello,

first of all, thank you very much for creating Respawn. I have enjoyed using the library so far.

We are running into problems because we have a table with a single row that should not be deleted. It is protected with a trigger that makes sure of that. I excluded the table from Respawn's processing, but it still triggers the exception that it's being deleted.

I saw that the generated SQL creates a 'truncate ... cascade' statement.

The way this apparently works is that Postgres just truncates any table that has a relationship with the truncated ones. This unfortunately means that the excluded table, still gets truncated (it has foreign keys with 'on cascade delete set null' set), which raises an error.

What would be the best way to deal with this issue? I would offer you a pull-request with the truncate removed, but I'm worried that there might be a good reason for it being there?

Thanks & best

Alon

@ayedo ayedo changed the title Issue with trunace cascade in Postgres Issue with truncate cascade in Postgres Nov 15, 2022
@jbogard
Copy link
Owner

jbogard commented Nov 19, 2022

Truncate is there because we had reports that it's faster. You can look at the history to see the original PR that added it.

I'm not a PG developer so I dunno the nuances here.

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

No branches or pull requests

2 participants