Spaces:
Paused
Paused
Download migrate_db.py from YOSOYYONOSOYOTRO/crowdata: direct link, hf CLI and curl.
- Browser
- Download file 773 Bytes
-
https://huggingface.co/spaces/YOSOYYONOSOYOTRO/crowdata/resolve/main/migrate_db.py
- Command line
-
hf download hf://spaces/YOSOYYONOSOYOTRO/crowdata/migrate_db.py
-
curl -L -o migrate_db.py https://huggingface.co/spaces/YOSOYYONOSOYOTRO/crowdata/resolve/main/migrate_db.py
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') |