Added db migration file
This commit is contained in:
parent
4a9fac5180
commit
dc0fad4c07
@ -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");
|
||||
});
|
||||
}
|
||||
};
|
||||
Loading…
Reference in New Issue
Block a user