Migrate status page table
This commit is contained in:
parent
1e2a8453c6
commit
72ce28a541
|
@ -9,7 +9,7 @@ CREATE TABLE [status_page](
|
|||
[theme] VARCHAR(30) NOT NULL,
|
||||
[published] BOOLEAN NOT NULL DEFAULT 1,
|
||||
[search_engine_index] BOOLEAN NOT NULL DEFAULT 1,
|
||||
[public] BOOLEAN NOT NULL DEFAULT 1,
|
||||
[show_tags] BOOLEAN NOT NULL DEFAULT 0,
|
||||
[password] VARCHAR
|
||||
);
|
||||
|
||||
|
|
|
@ -171,6 +171,7 @@ class Database {
|
|||
}
|
||||
|
||||
await this.patch2();
|
||||
await this.migrateNewStatusPage();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -212,6 +213,39 @@ class Database {
|
|||
await setSetting("databasePatchedFiles", databasePatchedFiles);
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate status page value in setting to "status_page" table
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
static async migrateNewStatusPage() {
|
||||
let title = await setting("title");
|
||||
|
||||
if (title) {
|
||||
console.log("Migrating Status Page");
|
||||
|
||||
let statusPageCheck = await R.findOne("status_page", " slug = '' ");
|
||||
|
||||
if (statusPageCheck !== null) {
|
||||
console.log("Migrating Status Page - Fail, empty slug record is already existing");
|
||||
return;
|
||||
}
|
||||
|
||||
let statusPage = R.dispense("status_page");
|
||||
statusPage.slug = "";
|
||||
statusPage.title = title;
|
||||
statusPage.icon = await setting("icon");
|
||||
statusPage.theme = await setting("statusPageTheme");
|
||||
statusPage.published = await setting("statusPagePublished");
|
||||
statusPage.search_engine_index = await setting("searchEngineIndex");
|
||||
statusPage.show_tags = await setting("statusPageTags");
|
||||
statusPage.password = null;
|
||||
await R.store(statusPage);
|
||||
await R.exec("DELETE FROM setting WHERE type = 'statusPage'");
|
||||
console.log("Migrating Status Page - Done");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Used it patch2() only
|
||||
* @param sqlFilename
|
||||
|
|
Loading…
Reference in New Issue