diff --git a/packages/server/modules/automate/migrations/20240523192300_add_is_test_automation_column.ts b/packages/server/modules/automate/migrations/20240523192300_add_is_test_automation_column.ts new file mode 100644 index 000000000..110177c5e --- /dev/null +++ b/packages/server/modules/automate/migrations/20240523192300_add_is_test_automation_column.ts @@ -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 { + 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 { + 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() + }) +} diff --git a/packages/server/modules/core/dbSchema.ts b/packages/server/modules/core/dbSchema.ts index 74da26edf..d1d128839 100644 --- a/packages/server/modules/core/dbSchema.ts +++ b/packages/server/modules/core/dbSchema.ts @@ -629,7 +629,8 @@ export const Automations = buildTableHelper('automations', [ 'createdAt', 'updatedAt', 'userId', - 'executionEngineAutomationId' + 'executionEngineAutomationId', + 'isTestAutomation' ]) export { knex }