refactor: Improve down migration logic for global column removal

This commit is contained in:
Raj Nandan Sharma
2026-02-25 22:37:37 +05:30
parent 28932f8df5
commit 5fd0e691b3
@@ -14,10 +14,12 @@ export async function up(knex: Knex): Promise<void> {
}
export async function down(knex: Knex): Promise<void> {
await knex.schema.table("incidents", (table) => {
table.dropColumn("is_global");
});
if (await knex.schema.hasTable("maintenances")) {
if (await knex.schema.hasColumn("incidents", "is_global")) {
await knex.schema.table("incidents", (table) => {
table.dropColumn("is_global");
});
}
if ((await knex.schema.hasTable("maintenances")) && (await knex.schema.hasColumn("maintenances", "is_global"))) {
await knex.schema.table("maintenances", (table) => {
table.dropColumn("is_global");
});