Files
Canto/qwen3-tts-backend/scripts/add_superuser_field.py
bdim404 80513a3258 init commit
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-26 15:34:31 +08:00

24 lines
761 B
Python

import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
from sqlalchemy import text
from core.database import engine
def add_superuser_field():
try:
with engine.connect() as conn:
conn.execute(text("ALTER TABLE users ADD COLUMN is_superuser BOOLEAN NOT NULL DEFAULT 0"))
conn.commit()
print("Successfully added is_superuser field to users table")
except Exception as e:
if "duplicate column name" in str(e).lower() or "already exists" in str(e).lower():
print("is_superuser field already exists, skipping")
else:
print(f"Error adding is_superuser field: {e}")
raise
if __name__ == "__main__":
add_superuser_field()