Adding augmented parts
This commit is contained in:
1 parent
2e7002b73b
commit
00fb43c8ed
14 files changed
+590
-2
No files matched your search
@@ -2,6 +2,7 @@
|
||||
|
||||
from app.models.associations import role_permissions, user_roles
|
||||
from app.models.audit_log import AuditLog
|
||||
from app.models.augmented_part import AugmentedPart
|
||||
from app.models.imported_part import ImportedPart
|
||||
from app.models.imported_part_config import ImportedPartConfig
|
||||
from app.models.iso_thread import IsoThread
|
||||
@@ -19,6 +20,7 @@ from app.models.user import User
|
||||
|
||||
__all__ = [
|
||||
"AuditLog",
|
||||
"AugmentedPart",
|
||||
"ImportedPart",
|
||||
"ImportedPartConfig",
|
||||
"IsoThread",
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
from sqlalchemy import ForeignKey, String
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from app.core.database import Base
|
||||
from app.models.manufacturer import Manufacturer
|
||||
from app.models.part_colour import PartColour
|
||||
from app.models.part_type import PartType
|
||||
from app.models.scope_model import ScopeModel
|
||||
from app.models.sub_part_type import SubPartType
|
||||
|
||||
|
||||
class AugmentedPart(Base):
|
||||
__tablename__ = "augmented_parts"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
sku: Mapped[str | None] = mapped_column(String, nullable=True, default=None)
|
||||
description: Mapped[str] = mapped_column(String, nullable=False)
|
||||
colour_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("part_colours.id", ondelete="RESTRICT"), nullable=False
|
||||
)
|
||||
manufacturer_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("manufacturers.id", ondelete="RESTRICT"), nullable=False
|
||||
)
|
||||
scope_model_id: Mapped[int | None] = mapped_column(
|
||||
ForeignKey("scope_models.id", ondelete="SET NULL"), nullable=True, default=None
|
||||
)
|
||||
part_type_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("part_types.id", ondelete="RESTRICT"), nullable=False
|
||||
)
|
||||
sub_part_type_id: Mapped[int | None] = mapped_column(
|
||||
ForeignKey("sub_part_types.id", ondelete="SET NULL"), nullable=True, default=None
|
||||
)
|
||||
|
||||
colour: Mapped[PartColour] = relationship(lazy="selectin")
|
||||
manufacturer: Mapped[Manufacturer] = relationship(lazy="selectin")
|
||||
scope_model: Mapped[ScopeModel | None] = relationship(lazy="selectin")
|
||||
part_type: Mapped[PartType] = relationship(lazy="selectin")
|
||||
sub_part_type: Mapped[SubPartType | None] = relationship(lazy="selectin")
|
||||
Reference in new issue
Block a user