fix(server): automation migration down problems

This commit is contained in:
Kristaps Fabians Geikins
2024-05-27 15:20:00 +03:00
parent e2064386cc
commit dc102d04ed
2 changed files with 7 additions and 4 deletions
@@ -56,10 +56,13 @@ export async function down(knex: Knex): Promise<void> {
// TODO: Remove, this is a temporary shortcut to avoid messing up the db schema which makes it difficult to jump to different branches
if (process.env.SKIP_AUTOMATE_MIGRATION_DEV) return
// delete invalid data
await knex.delete().from(AUTOMATION_RUNS_TABLE_NAME)
await knex.schema.alterTable(REVISIONS_TABLE_NAME, (table) => {
// old schema
table.jsonb('triggers').notNullable() // { "triggers": [{ "modelId": "asdf", "type": "commit"}...]}
table.boolean('published').notNullable()
table.jsonb('triggers').notNullable().defaultTo('[]')
table.boolean('published').notNullable().defaultTo(false)
})
await knex.schema.alterTable(AUTOMATION_RUNS_TABLE_NAME, (table) => {
table
@@ -50,8 +50,8 @@ export async function down(knex: Knex): Promise<void> {
})
await knex.schema.alterTable('automation_runs', (table) => {
table.jsonb('functionRuns').notNullable() // schema defined in code
table.jsonb('triggers').notNullable()
table.jsonb('functionRuns').notNullable().defaultTo('{}')
table.jsonb('triggers').notNullable().defaultTo('{}')
})
await knex.schema.alterTable('automation_revisions', (table) => {