From 59e7607e1adab0e5dc7396a9b1734273c81c2299 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Fri, 27 Sep 2024 21:42:20 +0800 Subject: [PATCH] wip --- server/database.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/server/database.js b/server/database.js index 317c21662..79ef091b0 100644 --- a/server/database.js +++ b/server/database.js @@ -735,7 +735,7 @@ class Database { log.debug("db", "Enter Migrate Aggregate Table function"); // - let migrated = false; + let migrated = Settings.get("migratedAggregateTable"); if (migrated) { log.debug("db", "Migrated, skip migration"); @@ -759,10 +759,20 @@ class Database { FROM heartbeat `); + // Show warning if stat_* tables are not empty + for (let table of [ "stat_minutely", "stat_hourly", "stat_daily" ]) { + let count = await trx(table).count("*").first(); + if (count.count > 0) { + log.warn("db", `Table ${table} is not empty, migration may cause data loss (Maybe you were using 2.0.0-dev?)`); + } + } + console.log("Dates", dates); console.log("Monitors", monitors); trx.commit(); + + //await Settings.set("migratedAggregateTable", true); } }