File size: 773 Bytes
4223796
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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')