Update app.py
Browse files
app.py
CHANGED
|
@@ -78,7 +78,7 @@ class UserProfile(Base):
|
|
| 78 |
email = Column(String, default="unknown@example.com")
|
| 79 |
preferences = Column(Text, default="")
|
| 80 |
last_interaction = Column(DateTime, default=datetime.utcnow)
|
| 81 |
-
order_ids = Column(Text, default="") #
|
| 82 |
|
| 83 |
class SentimentLog(Base):
|
| 84 |
__tablename__ = "sentiment_logs"
|
|
@@ -100,6 +100,14 @@ class OrderTracking(Base):
|
|
| 100 |
engine = create_async_engine(DATABASE_URL, echo=True)
|
| 101 |
async_session = sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)
|
| 102 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
async def init_db():
|
| 104 |
async with engine.begin() as conn:
|
| 105 |
await conn.run_sync(Base.metadata.create_all)
|
|
|
|
| 78 |
email = Column(String, default="unknown@example.com")
|
| 79 |
preferences = Column(Text, default="")
|
| 80 |
last_interaction = Column(DateTime, default=datetime.utcnow)
|
| 81 |
+
order_ids = Column(Text, default="") # New column
|
| 82 |
|
| 83 |
class SentimentLog(Base):
|
| 84 |
__tablename__ = "sentiment_logs"
|
|
|
|
| 100 |
engine = create_async_engine(DATABASE_URL, echo=True)
|
| 101 |
async_session = sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)
|
| 102 |
|
| 103 |
+
async def add_order_ids_column():
|
| 104 |
+
async with engine.connect() as conn:
|
| 105 |
+
await conn.execute(text("ALTER TABLE user_profiles ADD COLUMN order_ids TEXT DEFAULT ''"))
|
| 106 |
+
await conn.commit()
|
| 107 |
+
|
| 108 |
+
# Run the function to add the column
|
| 109 |
+
asyncio.run(add_order_ids_column())
|
| 110 |
+
|
| 111 |
async def init_db():
|
| 112 |
async with engine.begin() as conn:
|
| 113 |
await conn.run_sync(Base.metadata.create_all)
|