83 lines
2.1 KiB
Python
83 lines
2.1 KiB
Python
# backend/models.py
|
|
|
|
from sqlalchemy import Column, Integer, String, ForeignKey, DateTime
|
|
from sqlalchemy.orm import relationship, declarative_base
|
|
import datetime
|
|
from flask_sqlalchemy import SQLAlchemy
|
|
|
|
Base = declarative_base()
|
|
|
|
db = SQLAlchemy()
|
|
|
|
|
|
|
|
|
|
|
|
class Auditory(Base):
|
|
__tablename__ = 'auditories'
|
|
|
|
id = Column(Integer, primary_key=True)
|
|
audnazvanie = Column(String)
|
|
|
|
oboruds = relationship("Oboruds", back_populates="auditory")
|
|
|
|
|
|
class EquipmentType(Base):
|
|
__tablename__ = 'equipment_types'
|
|
|
|
id = Column(Integer, primary_key=True)
|
|
name = Column(String, unique=True, nullable=False)
|
|
|
|
oboruds = relationship("Oboruds", back_populates="type")
|
|
|
|
|
|
class Oboruds(Base):
|
|
__tablename__ = 'oboruds'
|
|
|
|
id = Column(Integer, primary_key=True)
|
|
invNumber = Column(Integer)
|
|
nazvanie = Column(String(500))
|
|
raspologenie = Column(String(200))
|
|
numberppasu = Column(String(100))
|
|
kolichestvo = Column(Integer)
|
|
|
|
aud_id = Column(Integer, ForeignKey("auditories.id"))
|
|
auditory = relationship("Auditory", back_populates="oboruds")
|
|
|
|
type_id = Column(Integer, ForeignKey("equipment_types.id"))
|
|
type = relationship("EquipmentType", back_populates="oboruds")
|
|
|
|
components = relationship("Component", back_populates="oborud")
|
|
consumables = relationship("Consumable", back_populates="oborud")
|
|
|
|
|
|
class Component(Base):
|
|
__tablename__ = 'components'
|
|
|
|
id = Column(Integer, primary_key=True)
|
|
name = Column(String, nullable=False)
|
|
description = Column(String)
|
|
|
|
oborud_id = Column(Integer, ForeignKey("oboruds.id"))
|
|
oborud = relationship("Oboruds", back_populates="components")
|
|
|
|
|
|
class Consumable(Base):
|
|
__tablename__ = 'consumables'
|
|
|
|
id = Column(Integer, primary_key=True)
|
|
name = Column(String, nullable=False)
|
|
description = Column(String)
|
|
|
|
oborud_id = Column(Integer, ForeignKey("oboruds.id"))
|
|
oborud = relationship("Oboruds", back_populates="consumables")
|
|
|
|
|
|
class Zametki(Base):
|
|
__tablename__ = 'zametki'
|
|
|
|
id = Column(Integer, primary_key=True)
|
|
txtzam = Column(String(10000))
|
|
created_date = Column(DateTime, default=datetime.datetime.utcnow)
|
|
rmdt = Column(DateTime)
|