fighting migrations

This commit is contained in:
Charles Driesler
2024-05-24 16:50:08 +01:00
parent caef83e967
commit eefeb8a240
2 changed files with 34 additions and 1 deletions
@@ -0,0 +1,32 @@
import { Knex } from 'knex'
const AUTOMATIONS_TABLE = 'automations'
const PLACEHOLDER_NULL_ID = 'null-execution-engine-automation-id'
export async function up(knex: Knex): Promise<void> {
await knex.schema.alterTable(AUTOMATIONS_TABLE, (table) => {
table.boolean('isTestAutomation').notNullable().defaultTo(false)
})
await knex.schema.alterTable(AUTOMATIONS_TABLE, (table) => {
table.setNullable('executionEngineAutomationId')
})
await knex(AUTOMATIONS_TABLE)
.where('executionEngineAutomationId', PLACEHOLDER_NULL_ID)
.update({ executionEngineAutomationId: null })
}
export async function down(knex: Knex): Promise<void> {
await knex.schema.alterTable(AUTOMATIONS_TABLE, (table) => {
table.dropColumn('isTestAutomation')
})
await knex(AUTOMATIONS_TABLE)
.whereNull('executionEngineAutomationId')
.update({ executionEngineAutomationId: PLACEHOLDER_NULL_ID })
await knex.schema.alterTable(AUTOMATIONS_TABLE, (table) => {
table.string('executionEngineAutomationId').notNullable().alter()
})
}
+2 -1
View File
@@ -629,7 +629,8 @@ export const Automations = buildTableHelper('automations', [
'createdAt',
'updatedAt',
'userId',
'executionEngineAutomationId'
'executionEngineAutomationId',
'isTestAutomation'
])
export { knex }