Adding sub-parts

This commit is contained in:
Ian Roddis committed 2026-06-25 15:14:37 -03:00
1 parent 45bc5bf8f6
commit c8696e67b5
14 files changed
+436 -2

No files matched your search

+2
View File
@@ -7,6 +7,7 @@ from app.models.manufacturer import Manufacturer
from app.models.part_type import PartType
from app.models.permission import Permission
from app.models.scope_model import ScopeModel
from app.models.sub_part_type import SubPartType
from app.models.refresh_token import RefreshToken
from app.models.role import Role
from app.models.unc_thread import UncThread
@@ -19,6 +20,7 @@ __all__ = [
"PartType",
"Permission",
"ScopeModel",
"SubPartType",
"RefreshToken",
"Role",
"UncThread",
+18
View File
@@ -0,0 +1,18 @@
from sqlalchemy import ForeignKey, UniqueConstraint
from sqlalchemy.orm import Mapped, mapped_column, relationship
from app.core.database import Base
from app.models.part_type import PartType
class SubPartType(Base):
__tablename__ = "sub_part_types"
__table_args__ = (UniqueConstraint("name", "part_type_id"),)
id: Mapped[int] = mapped_column(primary_key=True)
name: Mapped[str] = mapped_column(nullable=False)
part_type_id: Mapped[int] = mapped_column(
ForeignKey("part_types.id", ondelete="RESTRICT"), nullable=False
)
part_type: Mapped[PartType] = relationship(lazy="selectin")