优化系统初始化过程中数据库报错的问题
This commit is contained in:
@@ -575,16 +575,7 @@ app.post('/api/setup/init', ensureSetupAccess, async (req, res) => {
|
|||||||
VALUES (1, '数据可视化展示大屏', '数据可视化展示大屏', 'dark', 0, 'tx')
|
VALUES (1, '数据可视化展示大屏', '数据可视化展示大屏', 'dark', 0, 'tx')
|
||||||
`);
|
`);
|
||||||
|
|
||||||
// Ensure the first-run schema matches the runtime expectations without requiring a restart migration.
|
// Note: checkAndFixDatabase (called later in this route) will handle column migrations correctly and compatibly.
|
||||||
await connection.query("ALTER TABLE prometheus_sources ADD COLUMN IF NOT EXISTS is_server_source TINYINT(1) DEFAULT 1 AFTER description");
|
|
||||||
await connection.query("ALTER TABLE prometheus_sources ADD COLUMN IF NOT EXISTS type VARCHAR(50) DEFAULT 'prometheus' AFTER is_server_source");
|
|
||||||
await connection.query("ALTER TABLE site_settings ADD COLUMN IF NOT EXISTS show_page_name TINYINT(1) DEFAULT 1 AFTER page_name");
|
|
||||||
await connection.query("ALTER TABLE site_settings ADD COLUMN IF NOT EXISTS require_login_for_server_details TINYINT(1) DEFAULT 1 AFTER p95_type");
|
|
||||||
await connection.query("ALTER TABLE site_settings ADD COLUMN IF NOT EXISTS network_data_sources TEXT AFTER ps_filing");
|
|
||||||
await connection.query("ALTER TABLE site_settings ADD COLUMN IF NOT EXISTS show_server_ip TINYINT(1) DEFAULT 0 AFTER network_data_sources");
|
|
||||||
await connection.query("ALTER TABLE site_settings ADD COLUMN IF NOT EXISTS ip_metric_name VARCHAR(100) DEFAULT NULL AFTER show_server_ip");
|
|
||||||
await connection.query("ALTER TABLE site_settings ADD COLUMN IF NOT EXISTS ip_label_name VARCHAR(100) DEFAULT 'address' AFTER ip_metric_name");
|
|
||||||
await connection.query("ALTER TABLE site_settings ADD COLUMN IF NOT EXISTS custom_metrics JSON DEFAULT NULL AFTER ip_label_name");
|
|
||||||
await connection.query(`
|
await connection.query(`
|
||||||
CREATE TABLE IF NOT EXISTS latency_routes (
|
CREATE TABLE IF NOT EXISTS latency_routes (
|
||||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
@@ -645,6 +636,9 @@ ENABLE_EXTERNAL_GEO_LOOKUP=${process.env.ENABLE_EXTERNAL_GEO_LOOKUP || 'false'}
|
|||||||
db.initPool();
|
db.initPool();
|
||||||
cache.init();
|
cache.init();
|
||||||
|
|
||||||
|
// Run the migration/centralized schema tool to create/fix all tables
|
||||||
|
await checkAndFixDatabase();
|
||||||
|
|
||||||
isDbInitialized = true;
|
isDbInitialized = true;
|
||||||
res.json({ success: true, message: 'Initialization complete' });
|
res.json({ success: true, message: 'Initialization complete' });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user