Skip to content

Commit

Permalink
CASCADE on delete
Browse files Browse the repository at this point in the history
  • Loading branch information
gtfierro committed Nov 22, 2024
1 parent 8ddb49b commit db1e695
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions buildingmotif/database/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class DBModel(Base):
description: Mapped[str] = Column(Text(), default="", nullable=False)
graph_id: Mapped[str] = Column(String())
manifest_id: Mapped[int] = Column(
Integer, ForeignKey("shape_collection.id"), nullable=False
Integer, ForeignKey("shape_collection.id", ondelete="CASCADE"), nullable=False
)
manifest: "DBShapeCollection" = relationship(
"DBShapeCollection",
Expand Down Expand Up @@ -57,7 +57,7 @@ class DBLibrary(Base):
)

shape_collection_id = Column(
Integer, ForeignKey("shape_collection.id"), nullable=False
Integer, ForeignKey("shape_collection.id", ondelete="CASCADE"), nullable=False
)
shape_collection: DBShapeCollection = relationship(
"DBShapeCollection",
Expand All @@ -72,8 +72,8 @@ class DepsAssociation(Base):
__tablename__ = "deps_association_table"

id: Mapped[int] = Column(Integer, primary_key=True)
dependant_id: Mapped[int] = Column(ForeignKey("template.id"))
dependee_id: Mapped[int] = Column(ForeignKey("template.id"))
dependant_id: Mapped[int] = Column(ForeignKey("template.id", ondelete="CASCADE"))
dependee_id: Mapped[int] = Column(ForeignKey("template.id", ondelete="CASCADE"))
# args are a mapping of dependee args to dependant args
args: Mapped[Dict[str, str]] = Column(JSONType) # type: ignore

Expand All @@ -97,7 +97,7 @@ class DBTemplate(Base):
body_id: Mapped[str] = Column(String())
optional_args: Mapped[List[str]] = Column(JSONType) # type: ignore

library_id: Mapped[int] = Column(Integer, ForeignKey("library.id"), nullable=False)
library_id: Mapped[int] = Column(Integer, ForeignKey("library.id", ondelete="CASCADE"), nullable=False)
library: Mapped[DBLibrary] = relationship("DBLibrary", back_populates="templates")
dependencies: Mapped[List["DBTemplate"]] = relationship(
"DBTemplate",
Expand Down

0 comments on commit db1e695

Please sign in to comment.