mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-23 14:54:05 +00:00
wip
This commit is contained in:
parent
6be297fd46
commit
da8da0bf59
1 changed files with 8 additions and 1 deletions
|
@ -735,6 +735,12 @@ class Database {
|
|||
static async migrateAggregateTable() {
|
||||
log.debug("db", "Enter Migrate Aggregate Table function");
|
||||
|
||||
// Add a setting for 2.0.0-dev users to skip this migration
|
||||
if (process.env.SET_MIGRATE_AGGREGATE_TABLE_TO_TRUE === "1") {
|
||||
log.warn("db", "SET_MIGRATE_AGGREGATE_TABLE_TO_TRUE is set to 1, skipping aggregate table migration forever (for 2.0.0-dev users)");
|
||||
await Settings.set("migratedAggregateTable", true);
|
||||
}
|
||||
|
||||
//
|
||||
let migrated = await Settings.get("migratedAggregateTable");
|
||||
|
||||
|
@ -762,12 +768,13 @@ class Database {
|
|||
`);
|
||||
|
||||
// Stop if stat_* tables are not empty
|
||||
// SQL to empty these tables: DELETE FROM stat_minutely; DELETE FROM stat_hourly; DELETE FROM stat_daily;
|
||||
for (let table of [ "stat_minutely", "stat_hourly", "stat_daily" ]) {
|
||||
let countResult = await trx.raw(`SELECT COUNT(*) AS count FROM ${table}`);
|
||||
let count = countResult[0].count;
|
||||
if (count > 0) {
|
||||
log.warn("db", `Aggregate table ${table} is not empty, migration will not be started (Maybe you were using 2.0.0-dev?)`);
|
||||
trx.commit();
|
||||
trx.rollback();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue