"""Model (equipment model number) model.""" from shopdb.extensions import db from .base import BaseModel class Model(BaseModel): """Equipment/device model information.""" __tablename__ = 'models' modelnumberid = db.Column(db.Integer, primary_key=True) modelnumber = db.Column(db.String(100), nullable=False) # Link to machine type (what kind of equipment this model is for) machinetypeid = db.Column( db.Integer, db.ForeignKey('machinetypes.machinetypeid'), nullable=True ) # Link to vendor/manufacturer vendorid = db.Column( db.Integer, db.ForeignKey('vendors.vendorid'), nullable=True ) description = db.Column(db.Text) imageurl = db.Column(db.String(500), comment='URL to product image') documentationurl = db.Column(db.String(500), comment='URL to documentation') notes = db.Column(db.Text) # Relationships machinetype = db.relationship('MachineType', backref='models') vendor = db.relationship('Vendor', backref='models') # Unique constraint on modelnumber + vendor __table_args__ = ( db.UniqueConstraint('modelnumber', 'vendorid', name='uq_model_vendor'), ) def __repr__(self): return f""