Adding Attachment Points

This commit is contained in:
Ian Roddis committed 2026-07-02 14:06:18 -03:00
1 parent 2767fb1c8e
commit ceae27a12e
15 files changed
+729 -3

No files matched your search

+2
View File
@@ -1,6 +1,7 @@
"""Import all models so they register with ``Base.metadata``."""
from app.models.associations import augmented_part_imported_parts, role_permissions, user_roles
from app.models.attachment_point import AttachmentPoint
from app.models.attachment_point_name import AttachmentPointName
from app.models.audit_log import AuditLog
from app.models.augmented_part import AugmentedPart
@@ -21,6 +22,7 @@ from app.models.unc_thread import UncThread
from app.models.user import User
__all__ = [
"AttachmentPoint",
"AttachmentPointName",
"AuditLog",
"AugmentedPart",
+42
View File
@@ -0,0 +1,42 @@
from sqlalchemy import ForeignKey
from sqlalchemy.orm import Mapped, mapped_column, relationship
from app.core.database import Base
from app.models.attachment_point_name import AttachmentPointName
from app.models.clamp_connection import ClampConnection
from app.models.iso_thread import IsoThread
from app.models.static_connection import StaticConnection
from app.models.unc_thread import UncThread
class AttachmentPoint(Base):
__tablename__ = "attachment_points"
id: Mapped[int] = mapped_column(primary_key=True)
augmented_part_id: Mapped[int] = mapped_column(
ForeignKey("augmented_parts.id", ondelete="CASCADE"), nullable=False
)
attachment_point_name_id: Mapped[int] = mapped_column(
ForeignKey("attachment_point_names.id", ondelete="RESTRICT"), nullable=False
)
# Exactly one of the four below must be non-null (enforced in application layer)
iso_thread_id: Mapped[int | None] = mapped_column(
ForeignKey("iso_threads.id", ondelete="RESTRICT"), nullable=True, default=None
)
unc_thread_id: Mapped[int | None] = mapped_column(
ForeignKey("unc_threads.id", ondelete="RESTRICT"), nullable=True, default=None
)
clamp_connection_id: Mapped[int | None] = mapped_column(
ForeignKey("clamp_connections.id", ondelete="RESTRICT"), nullable=True, default=None
)
static_connection_id: Mapped[int | None] = mapped_column(
ForeignKey("static_connections.id", ondelete="RESTRICT"), nullable=True, default=None
)
attachment_point_name: Mapped[AttachmentPointName] = relationship(lazy="selectin")
iso_thread: Mapped[IsoThread | None] = relationship(lazy="selectin")
unc_thread: Mapped[UncThread | None] = relationship(lazy="selectin")
clamp_connection: Mapped[ClampConnection | None] = relationship(lazy="selectin")
static_connection: Mapped[StaticConnection | None] = relationship(lazy="selectin")