This commit is contained in:
Daniel
2026-03-04 16:48:17 +08:00
parent 64f4c438c3
commit 26938449f0
34 changed files with 956 additions and 500 deletions

View File

@@ -174,6 +174,7 @@ function runMigrations(db) {
if (!names.includes('region')) exec('ALTER TABLE key_location ADD COLUMN region TEXT')
if (!names.includes('status')) exec('ALTER TABLE key_location ADD COLUMN status TEXT DEFAULT "operational"')
if (!names.includes('damage_level')) exec('ALTER TABLE key_location ADD COLUMN damage_level INTEGER')
if (!names.includes('attacked_at')) exec('ALTER TABLE key_location ADD COLUMN attacked_at TEXT')
} catch (_) {}
try {
const lossCols = prepare('PRAGMA table_info(combat_losses)').all()
@@ -258,6 +259,38 @@ function runMigrations(db) {
INSERT OR IGNORE INTO display_stats (id) VALUES (1);
`)
} catch (_) {}
try {
const dsCols = prepare('PRAGMA table_info(display_stats)').all()
const dsNames = dsCols.map((c) => c.name)
if (!dsNames.includes('override_enabled')) {
exec('ALTER TABLE display_stats ADD COLUMN override_enabled INTEGER NOT NULL DEFAULT 0')
}
} catch (_) {}
try {
exec(`
CREATE TABLE IF NOT EXISTS map_strike_source (
id TEXT PRIMARY KEY,
name TEXT NOT NULL,
lng REAL NOT NULL,
lat REAL NOT NULL
);
CREATE TABLE IF NOT EXISTS map_strike_line (
source_id TEXT NOT NULL,
target_lng REAL NOT NULL,
target_lat REAL NOT NULL,
target_name TEXT,
struck_at TEXT,
FOREIGN KEY (source_id) REFERENCES map_strike_source(id)
);
CREATE INDEX IF NOT EXISTS idx_map_strike_line_source ON map_strike_line(source_id);
`)
} catch (_) {}
try {
const lineCols = prepare('PRAGMA table_info(map_strike_line)').all()
if (!lineCols.some((c) => c.name === 'struck_at')) {
exec('ALTER TABLE map_strike_line ADD COLUMN struck_at TEXT')
}
} catch (_) {}
}
async function initDb() {