Add migration script for discord_id and profile_picture columns
This commit is contained in:
37
backend/migrations/add_user_fields.py
Normal file
37
backend/migrations/add_user_fields.py
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
"""Add discord_id and profile_picture to users table."""
|
||||||
|
import sqlite3
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
def migrate():
|
||||||
|
"""Add new columns to users table."""
|
||||||
|
db_path = Path("/app/data/familyhub.db")
|
||||||
|
|
||||||
|
conn = sqlite3.connect(db_path)
|
||||||
|
cursor = conn.cursor()
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Add discord_id column
|
||||||
|
cursor.execute("ALTER TABLE users ADD COLUMN discord_id VARCHAR(100)")
|
||||||
|
print("✓ Added discord_id column")
|
||||||
|
except sqlite3.OperationalError as e:
|
||||||
|
if "duplicate column name" in str(e):
|
||||||
|
print("✓ discord_id column already exists")
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Add profile_picture column
|
||||||
|
cursor.execute("ALTER TABLE users ADD COLUMN profile_picture VARCHAR(500)")
|
||||||
|
print("✓ Added profile_picture column")
|
||||||
|
except sqlite3.OperationalError as e:
|
||||||
|
if "duplicate column name" in str(e):
|
||||||
|
print("✓ profile_picture column already exists")
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
|
||||||
|
conn.commit()
|
||||||
|
conn.close()
|
||||||
|
print("✓ Migration complete!")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
migrate()
|
||||||
Reference in New Issue
Block a user