mirror of
https://github.com/koichixD/uptime-kuma.git
synced 2026-08-29 01:01:01 +00:00
Added db migration file
This commit is contained in:
@@ -1,19 +0,0 @@
|
|||||||
/**
|
|
||||||
* @param {import("knex").Knex} knex Database connection
|
|
||||||
* @returns {Promise<void>}
|
|
||||||
*/
|
|
||||||
exports.up = async (knex) => {
|
|
||||||
await knex.schema.alterTable("monitor", (table) => {
|
|
||||||
table.string("system_service_name");
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {import("knex").Knex} knex Database connection
|
|
||||||
* @returns {Promise<void>}
|
|
||||||
*/
|
|
||||||
exports.down = async (knex) => {
|
|
||||||
await knex.schema.alterTable("monitor", (table) => {
|
|
||||||
table.dropColumn("system_service_name");
|
|
||||||
});
|
|
||||||
};
|
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/**
|
||||||
|
* @param {import("knex").Knex} knex
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
exports.up = async (knex) => {
|
||||||
|
const hasLocalServiceColumn = await knex.schema.hasColumn("monitor", "local_service_name");
|
||||||
|
const hasSystemServiceColumn = await knex.schema.hasColumn("monitor", "system_service_name");
|
||||||
|
|
||||||
|
if (hasLocalServiceColumn && !hasSystemServiceColumn) {
|
||||||
|
await knex.schema.alterTable("monitor", (table) => {
|
||||||
|
table.renameColumn("local_service_name", "system_service_name");
|
||||||
|
});
|
||||||
|
} else if (!hasSystemServiceColumn) {
|
||||||
|
await knex.schema.alterTable("monitor", (table) => {
|
||||||
|
table.string("system_service_name");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {import("knex").Knex} knex
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
exports.down = async (knex) => {
|
||||||
|
const hasSystemServiceColumn = await knex.schema.hasColumn("monitor", "system_service_name");
|
||||||
|
if (hasSystemServiceColumn) {
|
||||||
|
await knex.schema.alterTable("monitor", (table) => {
|
||||||
|
table.renameColumn("system_service_name", "local_service_name");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user