starpost: contain prestaged cargo buyers

This commit is contained in:
scandalist-trash committed 2026-10-25 08:49:26 -04:00
1 parent b28069ecfc
commit b5bbafc664
4 files changed
+52 -16

No files matched your search

+10
View File
@@ -5,6 +5,7 @@ from psycopg.rows import dict_row
DATABASE_URL = os.environ["DATABASE_URL"]
CARGO_PURCHASE_WINDOW_SECONDS = 2
def connect():
@@ -28,6 +29,15 @@ def migrate():
cursor.execute("ALTER TABLE orders ADD COLUMN IF NOT EXISTS warehouse_status TEXT NOT NULL DEFAULT 'queued'")
cursor.execute("ALTER TABLE orders ADD COLUMN IF NOT EXISTS warehouse_job_id TEXT")
cursor.execute("ALTER TABLE orders ADD COLUMN IF NOT EXISTS warehouse_updated_at TIMESTAMPTZ NOT NULL DEFAULT now()")
cursor.execute("ALTER TABLE orders ADD COLUMN IF NOT EXISTS cargo_entitled BOOLEAN")
cursor.execute(
"UPDATE orders o SET cargo_entitled="
"(o.created_at <= p.created_at + (%s * interval '1 second')) "
"FROM products p WHERE p.id=o.product_id AND o.cargo_entitled IS NULL",
(CARGO_PURCHASE_WINDOW_SECONDS,),
)
cursor.execute("ALTER TABLE orders ALTER COLUMN cargo_entitled SET DEFAULT false")
cursor.execute("ALTER TABLE orders ALTER COLUMN cargo_entitled SET NOT NULL")
cursor.execute(
"""
CREATE TABLE IF NOT EXISTS promo_codes (