elmeg-demo/backend/add_parent_id_column.py
fullsizemalt a75921d633
Some checks are pending
Deploy Elmeg / deploy (push) Waiting to run
feat(social): Add threaded comments backend support
2025-12-21 02:43:00 -08:00

15 lines
548 B
Python

from sqlmodel import Session, create_engine, text
from database import DATABASE_URL
def add_column():
engine = create_engine(DATABASE_URL)
with Session(engine) as session:
try:
session.exec(text("ALTER TABLE comment ADD COLUMN parent_id INTEGER REFERENCES comment(id)"))
session.commit()
print("Successfully added parent_id column to comment table")
except Exception as e:
print(f"Error adding column (might already exist): {e}")
if __name__ == "__main__":
add_column()