feat(server): add attachment ORM models and table provisioning
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>
This commit is contained in:
39
scripts/create_attachment_tables.py
Normal file
39
scripts/create_attachment_tables.py
Normal file
@@ -0,0 +1,39 @@
|
||||
"""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()
|
||||
Reference in New Issue
Block a user