Update app.py
Browse files
app.py
CHANGED
|
@@ -103,12 +103,12 @@ async_session = sessionmaker(engine, class_=AsyncSession, expire_on_commit=False
|
|
| 103 |
# --- Migration Functions ---
|
| 104 |
async def add_order_ids_column():
|
| 105 |
async with engine.connect() as conn:
|
| 106 |
-
#
|
| 107 |
await conn.execute(
|
| 108 |
text("ALTER TABLE user_profiles ADD COLUMN IF NOT EXISTS order_ids TEXT DEFAULT ''")
|
| 109 |
)
|
| 110 |
await conn.commit()
|
| 111 |
-
print("Column 'order_ids'
|
| 112 |
|
| 113 |
async def init_db():
|
| 114 |
async with engine.begin() as conn:
|
|
|
|
| 103 |
# --- Migration Functions ---
|
| 104 |
async def add_order_ids_column():
|
| 105 |
async with engine.connect() as conn:
|
| 106 |
+
# Ensure the column exists (PostgreSQL 9.6+ supports IF NOT EXISTS)
|
| 107 |
await conn.execute(
|
| 108 |
text("ALTER TABLE user_profiles ADD COLUMN IF NOT EXISTS order_ids TEXT DEFAULT ''")
|
| 109 |
)
|
| 110 |
await conn.commit()
|
| 111 |
+
print("Column 'order_ids' ensured on user_profiles.")
|
| 112 |
|
| 113 |
async def init_db():
|
| 114 |
async with engine.begin() as conn:
|