mirror of
https://github.com/louislam/uptime-kuma.git
synced 2026-01-31 11:03:11 +08:00
Added db migration file
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* @param {import("knex").Knex} knex The Knex.js instance for database interaction.
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
exports.up = async (knex) => {
|
||||
await knex.schema.alterTable("monitor", (table) => {
|
||||
table.string("system_service_name");
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {import("knex").Knex} knex The Knex.js instance for database interaction.
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
exports.down = async (knex) => {
|
||||
await knex.schema.alterTable("monitor", (table) => {
|
||||
table.dropColumn("system_service_name");
|
||||
});
|
||||
};
|
||||
@@ -1,31 +0,0 @@
|
||||
/**
|
||||
* @param {import("knex").Knex} knex The Knex.js instance for database interaction.
|
||||
* @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 The Knex.js instance for database interaction.
|
||||
* @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