Retire the legacy Machine model (ADR-001 cutover)

The asset/computer model is now the single source of truth. Remove the Machine
instance layer end to end:

- Delete models Machine, MachineStatus, PCType, MachineRelationship,
  InstalledApp, PrinterData; keep MachineType (models.machinetypeid still
  references it).
- Delete the /api/machines, /api/statuses, /api/pctypes blueprints and the
  legacy /api/printers/legacy (PrinterData) blueprint.
- Drop the deprecated communications.machineid column and its FK.
- Migration 7c01 drops tables machines, machinestatuses, pctypes,
  machinerelationships, installedapps, printerdata (idempotent).
- Fix remaining readers (applications install counts) to ComputerInstalledApp.
- Frontend: remove dead machinesApi/statusesApi/pctypesApi wrappers; repoint
  the PC Types settings page at computer types.

143 tests pass; all asset/computer/dashboard/report/collector endpoints 200.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
cproudlock
2026-06-26 09:59:17 -04:00
parent cb47b9087e
commit b0a0670fcd
23 changed files with 344 additions and 2047 deletions

View File

@@ -42,7 +42,7 @@ def seed_cli():
def seed_reference_data():
"""Seed reference data (machine types, statuses, etc.)."""
from shopdb.extensions import db
from shopdb.core.models import MachineType, MachineStatus, OperatingSystem, AssetStatus
from shopdb.core.models import MachineType, OperatingSystem, AssetStatus
from shopdb.core.models.relationship import RelationshipType
# Machine types
@@ -67,21 +67,6 @@ def seed_reference_data():
mt = MachineType(**mt_data)
db.session.add(mt)
# Machine statuses
statuses = [
{'status': 'In Use', 'description': 'Currently in use', 'color': '#28a745'},
{'status': 'Spare', 'description': 'Available as spare', 'color': '#17a2b8'},
{'status': 'Retired', 'description': 'No longer in use', 'color': '#6c757d'},
{'status': 'In Repair', 'description': 'Currently being repaired', 'color': '#ffc107'},
{'status': 'Pending', 'description': 'Pending installation', 'color': '#007bff'},
]
for s_data in statuses:
existing = MachineStatus.query.filter_by(status=s_data['status']).first()
if not existing:
s = MachineStatus(**s_data)
db.session.add(s)
# Asset statuses (canonical set - the asset model is the contract)
asset_statuses = [
{'status': 'In Use', 'description': 'Currently in use', 'color': '#28a745'},