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

Update sql schema with on delete/update cascade #1338

Conversation

brdandu
Copy link
Collaborator

@brdandu brdandu commented Jun 12, 2024

Update sql schema with on delete and update cascades such that when the primary key is deleted or updated then the associated child tables are reflected for those deletes and updates properly. This should fix some of our sql constraint violations during inserts because sometimes we may just have leftover entries from deleted records.

JIRA: ZAPP-1154

…he primary key is deleted or updated then the associated child tables are reflected for those deletes and updates properly. This should fix some of our sql constraint violations during inserts because sometimes we may just have leftover entries from deleted records.

JIRA: ZAPP-1154
@brdandu brdandu requested review from tecimovic and paulr34 June 12, 2024 18:39
@@ -36,7 +36,7 @@ CREATE TABLE "PACKAGE" (
"VERSION" integer,
"CATEGORY" text,
"DESCRIPTION" text,
foreign key (PARENT_PACKAGE_REF) references PACKAGE(PACKAGE_ID)
foreign key (PARENT_PACKAGE_REF) references PACKAGE(PACKAGE_ID) ON DELETE CASCADE ON UPDATE CASCADE
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ON UPDATE CASCADE will update the foreign-key if someone updates the primary key.

Why and where are we ever updating primary keys?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update probably won't fix any underlying issues I know off.
Just a precaution more than anything else. I did not have a concrete reason to add it

@brdandu brdandu merged commit fb649e5 into project-chip:master Jun 13, 2024
13 checks passed
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 this pull request may close these issues.

3 participants