File size: 670 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
import sqlite3
conn = sqlite3.connect('crowdata.db')
cursor = conn.cursor()

# Add MFA columns
for col, col_type in [
    ('mfa_enabled', 'BOOLEAN DEFAULT FALSE'),
    ('mfa_secret', 'VARCHAR(255)'),
    ('mfa_backup_codes', 'VARCHAR(500)'),
    ('mfa_verified_at', 'DATETIME')
]:
    try:
        cursor.execute(f'ALTER TABLE users ADD COLUMN {col} {col_type}')
        print(f'Added column: {col}')
    except Exception as e:
        if 'duplicate' in str(e).lower() or 'already exists' in str(e).lower():
            print(f'Column already exists: {col}')
        else:
            print(f'Error adding {col}: {e}')

conn.commit()
conn.close()
print('Migration done')