|
|
|
|
@ -1,19 +1,32 @@
|
|
|
|
|
|
|
|
|
|
from sqlalchemy import UUID, Column, Float, ForeignKey, Integer, String
|
|
|
|
|
from src.database.core import Base
|
|
|
|
|
from src.models import DefaultMixin
|
|
|
|
|
from sqlalchemy.orm import relationship, declarative_base, declared_attr, remote, foreign, backref
|
|
|
|
|
from sqlalchemy.orm import (
|
|
|
|
|
relationship,
|
|
|
|
|
declarative_base,
|
|
|
|
|
declared_attr,
|
|
|
|
|
remote,
|
|
|
|
|
foreign,
|
|
|
|
|
backref,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class EquipmentMaster(Base, DefaultMixin):
|
|
|
|
|
__table_args__ = {"extend_existing": True}
|
|
|
|
|
__tablename__ = "ms_equipment_master"
|
|
|
|
|
|
|
|
|
|
id = Column(UUID(as_uuid=True), primary_key=True, index=True)
|
|
|
|
|
name = Column(String, nullable=False)
|
|
|
|
|
parent_id = Column(UUID(as_uuid=True), ForeignKey(
|
|
|
|
|
'ms_equipment_master.id', ondelete='CASCADE'), nullable=True)
|
|
|
|
|
equipment_tree_id = Column(UUID(as_uuid=True), ForeignKey(
|
|
|
|
|
'ms_equipment_tree.id', ondelete='CASCADE'), nullable=True)
|
|
|
|
|
parent_id = Column(
|
|
|
|
|
UUID(as_uuid=True),
|
|
|
|
|
ForeignKey("ms_equipment_master.id", ondelete="CASCADE"),
|
|
|
|
|
nullable=True,
|
|
|
|
|
)
|
|
|
|
|
equipment_tree_id = Column(
|
|
|
|
|
UUID(as_uuid=True),
|
|
|
|
|
ForeignKey("ms_equipment_tree.id", ondelete="CASCADE"),
|
|
|
|
|
nullable=True,
|
|
|
|
|
)
|
|
|
|
|
category_id = Column(UUID(as_uuid=True), nullable=True)
|
|
|
|
|
system_tag = Column(String, nullable=True)
|
|
|
|
|
assetnum = Column(String, nullable=True)
|
|
|
|
|
@ -22,15 +35,13 @@ class EquipmentMaster(Base, DefaultMixin):
|
|
|
|
|
# Relationship definitions
|
|
|
|
|
# Define both sides of the relationship
|
|
|
|
|
# parent = relationship(
|
|
|
|
|
# "EquipmentMaster",
|
|
|
|
|
# "EquipmentMaster",
|
|
|
|
|
# back_populates="children",
|
|
|
|
|
# remote_side=[id]
|
|
|
|
|
# )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
children = relationship(
|
|
|
|
|
"EquipmentMaster",
|
|
|
|
|
backref=backref("parent", remote_side=[id]),
|
|
|
|
|
lazy="selectin"
|
|
|
|
|
"EquipmentMaster", backref=backref("parent", remote_side=[id]), lazy="selectin"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# equipment_tree = relationship(
|
|
|
|
|
|