File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 1+ from app .main import create_app
2+ from app .models import db , User
3+ from app .config import Config
4+
5+ app = create_app ()
6+
7+ with app .app_context ():
8+ # Add new columns to existing users
9+ users = User .query .all ()
10+
11+ # If global settings exist, migrate them to admin user
12+ admin = User .query .filter_by (username = 'admin' ).first ()
13+ if admin and hasattr (Config , 'DA_SERVER' ):
14+ print ("Migrating global DirectAdmin settings to admin user..." )
15+ admin .da_server = Config .DA_SERVER
16+ admin .da_username = Config .DA_USERNAME
17+ admin .da_domain = Config .DA_DOMAIN
18+
19+ # Generate encryption key if not exists
20+ if not admin .encryption_key :
21+ from cryptography .fernet import Fernet
22+ admin .encryption_key = Fernet .generate_key ().decode ()
23+
24+ # Encrypt and store password
25+ if hasattr (Config , 'DA_PASSWORD' ):
26+ admin .set_da_password (Config .DA_PASSWORD )
27+
28+ db .session .commit ()
29+ print ("Migration completed!" )
You can’t perform that action at this time.
0 commit comments