Adds 5 tables in the CargoTrace schema: attachment_category, finished_goods_attachment, finished_goods_attachment_item, finished_goods_attachment_location, finished_goods_box_attachment_item. Includes a one-off create_all script and extends test cleanup. Co-Authored-By: Claude <noreply@anthropic.com>
40 lines
937 B
Python
40 lines
937 B
Python
"""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()
|