38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
"""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()
|