mirror of
				https://github.com/louislam/uptime-kuma.git
				synced 2025-11-01 03:49:24 +08:00 
			
		
		
		
	Migrate status page table
This commit is contained in:
		| @@ -9,7 +9,7 @@ CREATE TABLE [status_page]( | |||||||
|     [theme] VARCHAR(30) NOT NULL, |     [theme] VARCHAR(30) NOT NULL, | ||||||
|     [published] BOOLEAN NOT NULL DEFAULT 1, |     [published] BOOLEAN NOT NULL DEFAULT 1, | ||||||
|     [search_engine_index] 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 |     [password] VARCHAR | ||||||
| ); | ); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -171,6 +171,7 @@ class Database { | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         await this.patch2(); |         await this.patch2(); | ||||||
|  |         await this.migrateNewStatusPage(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
| @@ -212,6 +213,39 @@ class Database { | |||||||
|         await setSetting("databasePatchedFiles", databasePatchedFiles); |         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 |      * Used it patch2() only | ||||||
|      * @param sqlFilename |      * @param sqlFilename | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user