"""One-off: create the 5 attachment tables in the configured DB. Run from services/fastapi/ with the venv active: python scripts/create_attachment_tables.py """ import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) from app.core.database import Base, engine # noqa: E402 from app.models.attachment import ( # noqa: E402 AttachmentCategory, FinishedGoodsAttachment, FinishedGoodsAttachmentItem, FinishedGoodsAttachmentLocation, FinishedGoodsBoxAttachmentItem, ) NEW_TABLES = [ AttachmentCategory, FinishedGoodsAttachment, FinishedGoodsAttachmentItem, FinishedGoodsAttachmentLocation, FinishedGoodsBoxAttachmentItem, ] def main() -> None: Base.metadata.create_all( engine, tables=[t.__table__ for t in NEW_TABLES], ) print(f"Created {len(NEW_TABLES)} attachment tables.") if __name__ == "__main__": main()