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:
Misaka_Company
2026-08-12 13:32:26 +08:00
parent eec0fd3189
commit baa841ae42
5 changed files with 248 additions and 1 deletions

View File

@@ -0,0 +1,22 @@
from sqlalchemy.orm import Session
from app.models.attachment import AttachmentCategory, FinishedGoodsAttachment
def test_category_round_trip(db: Session):
cat = AttachmentCategory(name="TEST_SMOKE", sort_order=1, is_active=True)
db.add(cat)
db.commit()
db.refresh(cat)
assert cat.id is not None
fetched = db.query(AttachmentCategory).filter_by(name="TEST_SMOKE").first()
assert fetched is not None
assert fetched.is_active is True
def test_attachment_defaults_to_undetermined(db: Session):
att = FinishedGoodsAttachment(zongpai_no="26BW0011")
db.add(att)
db.commit()
db.refresh(att)
assert att.determination == "undetermined"