Guard against missing marketplace tables when recording inventory operations
Some checks failed
CI / lint-and-test (3.11) (push) Has been cancelled
CI / lint-and-test (3.13) (push) Has been cancelled

This commit is contained in:
2026-07-18 04:47:46 +00:00
parent 6d07eab5c0
commit 4a4e53602b

View File

@@ -122,7 +122,15 @@ def record_operation(conn, inventory_id, branch_id, operation_type, quantity,
))
op_id = cur.fetchone()[0]
# Queue ML stock sync if this product has an active ML listing
# Queue ML stock sync if this product has an active ML listing.
# Skip gracefully if the marketplace tables do not exist in this tenant.
cur.execute("""
SELECT 1 FROM information_schema.tables
WHERE table_schema = 'public'
AND table_name IN ('marketplace_listings', 'meli_sync_queue')
LIMIT 1
""")
if cur.fetchone():
cur.execute("""
INSERT INTO meli_sync_queue (inventory_id, action, status)
SELECT %s, 'stock_update', 'pending'