The equipment plugin is now the machines plugin, ending the UI-vs-code vocabulary split while the contract is pre-1.0 and nothing external depends on the old names. - plugins/equipment -> plugins/machines: manifest, class, /api/machines, machines.* permissions, registry key (with an auto-migrating load shim for existing installs). - Tables: equipment -> machines (equipmentid -> machineid) and equipmenttypes -> machinetypes, renamed in the plugin's own migration chain (machines0002rename), idempotent for both upgrading and fresh installs. - The legacy core machinetypes lookup actually types the vendor MODELS catalog, so it is renamed losslessly to modeltypes (models.modeltypeid, /api/modeltypes, Model Types settings page) rather than collapsed, freeing the machinetypes name. Core migration 7d17_machines_rename also flips data in place: assettypes row equipment -> machine, auditlog entitytype, identifier_/search_ settings keys, permission rows, and renames alembic_version_equipment. - Frontend: machinesApi/modeltypesApi, item.machine response shape, assettype value compares 'equipment' -> 'machine' (map, search, custom fields, relationships), routes machines.js with plugin gating retagged, /print/machine-badge, Machine Types (subtypes) and Model Types (catalog) settings pages, machines-by-type report id. - Docs swept; ADRs left as history per the authoring rule. Upgrade: flask db upgrade then flask plugin upgrade-all. Verified: dev DB flipped live (262 machines, 35 modeltypes, 95 models retyped, zero equipment tables remain); fresh scratch-MySQL install produces the new names; 341 tests green; naming/style green; frontend builds; live E2E on machines list/detail, PC relationships, map, reports, and both settings pages. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
"""Model (vendor catalog model number) model."""
|
|
|
|
from shopdb.extensions import db
|
|
from .base import BaseModel
|
|
|
|
|
|
class Model(BaseModel):
|
|
"""Vendor catalog model information (machines, PCs, printers, network)."""
|
|
__tablename__ = 'models'
|
|
|
|
modelnumberid = db.Column(db.Integer, primary_key=True)
|
|
modelnumber = db.Column(db.String(100), nullable=False)
|
|
|
|
# Link to model type (what kind of thing this catalog model is for)
|
|
modeltypeid = db.Column(
|
|
db.Integer,
|
|
db.ForeignKey('modeltypes.modeltypeid'),
|
|
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
|
|
modeltype = db.relationship('ModelType', 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"<Model {self.modelnumber}>"
|