Migrate panel DB from MySQL to SQLite

Panel no longer depends on the user-managed MariaDB service.
SQLite at /var/lib/novacpx/panel.db runs independently so the
control panel stays up even when MariaDB is stopped.

- DB.php: switch to sqlite: DSN, add SQL translator (ON DUPLICATE KEY,
  DATE_ADD/DATE_SUB INTERVAL, NOW(), UNIX_TIMESTAMP(), IFNULL)
- Core.php: replace DB_HOST/NAME/USER/PASS with DB_PATH constant
- schema.sql: full SQLite syntax, add TOTP columns to users table
- _branding.php: use sqlite: PDO, datetime('now') for session check
- install.sh: apt install sqlite3, create SQLite DB instead of MySQL DB
- tools/migrate-to-sqlite.sh: one-shot migration script for existing installs
This commit is contained in:
2026-06-09 14:52:02 +00:00
parent 9bd78a81ea
commit fbc445dad2
5 changed files with 713 additions and 335 deletions
+3 -4
View File
@@ -13,10 +13,9 @@ if (!$_cfg) {
die(json_encode(['error' => 'NovaCPX not configured. Run the installer.']));
}
define('DB_HOST', $_cfg['database']['host'] ?? 'localhost');
define('DB_NAME', $_cfg['database']['name'] ?? 'novacpx');
define('DB_USER', $_cfg['database']['user'] ?? '');
define('DB_PASS', $_cfg['database']['pass'] ?? '');
define('DB_PATH', $_cfg['database']['path'] ?? '/var/lib/novacpx/panel.db');
define('DB_WP_USER', $_cfg['database']['wp_user'] ?? '');
define('DB_WP_PASS', $_cfg['database']['wp_pass'] ?? '');
define('SECRET_KEY', $_cfg['panel']['secret'] ?? '');
define('PANEL_VER', $_cfg['panel']['version'] ?? NOVACPX_VERSION);
define('PORT_USER', (int)($_cfg['panel']['port_user'] ?? 8880));