Replies: 1 comment
-
I think I can find the orphaned audits by checking if the const orphanedAudits = await db
.select({ id: audits.id })
.from(audits)
.leftJoin(auditsToReports, eq(audits.id, auditsToReports.auditId))
.where(isNull(auditsToReports.auditId)) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I’m using the beta RGB-v2, and I have a many-to-many relations from audits to reports.
Schema and relations
The junction table:
When I delete the "Report A", the deletion cascades to the junction tables just fine, but not to the the audits.
And if I query the related audit ids to delete them, I will get all of them ofc, but some of them are related to other reports and should not be deleted.
Is there a smart way not to delete the shared audits? All I can think of is to peruse the database periodically looking for orphaned audits.
Similar question:
Beta Was this translation helpful? Give feedback.
All reactions