Skip to content

Commit a83443d

Browse files
committed
checkpoint: cascading delete on Invoice.items
1 parent ca674d8 commit a83443d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tuttle/model.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,10 @@ class Invoice(SQLModel, table=True):
586586
# invoice items
587587
items: List["InvoiceItem"] = Relationship(
588588
back_populates="invoice",
589-
sa_relationship_kwargs={"lazy": "subquery"},
589+
sa_relationship_kwargs={
590+
"lazy": "subquery",
591+
"cascade": "all, delete", # delete all invoice items when invoice is deleted
592+
},
590593
)
591594
rendered: bool = Field(
592595
default=False,

0 commit comments

Comments
 (0)