27 lines
715 B
Python
27 lines
715 B
Python
"""Add profile_image column to users table."""
|
|
import sqlite3
|
|
import os
|
|
|
|
db_path = os.path.join(os.path.dirname(__file__), '..', 'data', 'aufmass.db')
|
|
db_path = os.path.normpath(db_path)
|
|
|
|
if not os.path.exists(db_path):
|
|
print(f"DB not found at {db_path}")
|
|
exit(0)
|
|
|
|
conn = sqlite3.connect(db_path)
|
|
cursor = conn.cursor()
|
|
|
|
# Check if column already exists
|
|
cursor.execute("PRAGMA table_info(users)")
|
|
cols = [row[1] for row in cursor.fetchall()]
|
|
if 'profile_image' not in cols:
|
|
cursor.execute("ALTER TABLE users ADD COLUMN profile_image VARCHAR(255)")
|
|
print("Added profile_image column to users table.")
|
|
else:
|
|
print("Column profile_image already exists.")
|
|
|
|
conn.commit()
|
|
conn.close()
|
|
print("Done.")
|