crowdata / migrate_db.py
YOSOYYONOSOYOTRO's picture
Upload folder using huggingface_hub (part 2)
4223796 verified
Raw
History Blame Contribute Delete
773 Bytes
import sqlite3
conn = sqlite3.connect('E:/crowdata/backend/crowdata.db')
cursor = conn.cursor()
# Add missing columns
columns_to_add = [
('failed_login_attempts', 'INTEGER DEFAULT 0'),
('locked_until', 'DATETIME'),
('oauth_provider', 'VARCHAR(50)'),
('oauth_provider_id', 'VARCHAR(255)'),
('password_strength_score', 'INTEGER'),
]
for col_name, col_type in columns_to_add:
try:
cursor.execute(f'ALTER TABLE users ADD COLUMN {col_name} {col_type}')
print(f'Added column: {col_name}')
except sqlite3.OperationalError as e:
if 'duplicate column name' in str(e).lower():
print(f'Column {col_name} already exists, skipping')
else:
raise
conn.commit()
conn.close()
print('Migration complete')