diff --git a/db/patch-status-page.sql b/db/patch-status-page.sql index 18986403c..07eacc023 100644 --- a/db/patch-status-page.sql +++ b/db/patch-status-page.sql @@ -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 ); diff --git a/server/database.js b/server/database.js index fcef91719..119289e6a 100644 --- a/server/database.js +++ b/server/database.js @@ -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} + */ + 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