添加db_migrate功能
This commit is contained in:
@@ -204,7 +204,7 @@ async function ensureTable(tableName, tableSchema) {
|
||||
}
|
||||
}
|
||||
|
||||
async function checkAndFixDatabase() {
|
||||
async function db_migrate() {
|
||||
console.log('[Database Integrity] Starting comprehensive database audit...');
|
||||
|
||||
// Try to check if we can even connect
|
||||
@@ -233,4 +233,4 @@ async function checkAndFixDatabase() {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = checkAndFixDatabase;
|
||||
module.exports = db_migrate;
|
||||
|
||||
@@ -7,7 +7,7 @@ const prometheusService = require('./prometheus-service');
|
||||
const cache = require('./cache');
|
||||
const geoService = require('./geo-service');
|
||||
const latencyService = require('./latency-service');
|
||||
const checkAndFixDatabase = require('./db-schema-check');
|
||||
const db_migrate = require('./db-schema-check');
|
||||
const http = require('http');
|
||||
const WebSocket = require('ws');
|
||||
const net = require('net');
|
||||
@@ -651,7 +651,7 @@ APP_SECRET=${process.env.APP_SECRET || APP_SECRET}
|
||||
cache.init();
|
||||
|
||||
// Run the migration/centralized schema tool to create/fix all tables
|
||||
await checkAndFixDatabase();
|
||||
await db_migrate();
|
||||
|
||||
isDbInitialized = true;
|
||||
res.json({ success: true, message: 'Initialization complete' });
|
||||
@@ -1509,7 +1509,7 @@ async function start() {
|
||||
|
||||
// 2. Automated repair/migration
|
||||
try {
|
||||
const dbFixed = await checkAndFixDatabase();
|
||||
const dbFixed = await db_migrate();
|
||||
if (dbFixed) {
|
||||
// Refresh state after fix
|
||||
await checkDb();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const path = require('path');
|
||||
require('dotenv').config({ path: path.join(__dirname, '..', '.env') });
|
||||
const mysql = require('mysql2/promise');
|
||||
const checkAndFixDatabase = require('./db-schema-check');
|
||||
const db_migrate = require('./db-schema-check');
|
||||
const db = require('./db');
|
||||
|
||||
async function initDatabase() {
|
||||
@@ -31,7 +31,7 @@ async function initDatabase() {
|
||||
|
||||
// 3. Use the centralized schema tool to create/fix all tables
|
||||
console.log(' 📦 Initializing tables using schema-check tool...');
|
||||
await checkAndFixDatabase();
|
||||
await db_migrate();
|
||||
console.log(' ✅ Tables and columns ready');
|
||||
|
||||
console.log('\n🎉 Database initialization complete!\n');
|
||||
|
||||
Reference in New Issue
Block a user