From c41d27e1aeabfb3ccf6070c2c1e392599400941a Mon Sep 17 00:00:00 2001 From: Sheen Capadngan Date: Thu, 21 Nov 2024 21:27:56 +0800 Subject: [PATCH] misc: made identity metadata value not nullable --- ...ke-identity-metadata-not-nullable-again.ts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 backend/src/db/migrations/20241121131344_make-identity-metadata-not-nullable-again.ts diff --git a/backend/src/db/migrations/20241121131344_make-identity-metadata-not-nullable-again.ts b/backend/src/db/migrations/20241121131344_make-identity-metadata-not-nullable-again.ts new file mode 100644 index 000000000..fb58c02df --- /dev/null +++ b/backend/src/db/migrations/20241121131344_make-identity-metadata-not-nullable-again.ts @@ -0,0 +1,20 @@ +import { Knex } from "knex"; + +import { TableName } from "../schemas"; + +export async function up(knex: Knex): Promise { + if (await knex.schema.hasColumn(TableName.IdentityMetadata, "value")) { + await knex(TableName.IdentityMetadata).whereNull("value").delete(); + await knex.schema.alterTable(TableName.IdentityMetadata, (t) => { + t.string("value", 1020).notNullable().alter(); + }); + } +} + +export async function down(knex: Knex): Promise { + if (await knex.schema.hasColumn(TableName.IdentityMetadata, "value")) { + await knex.schema.alterTable(TableName.IdentityMetadata, (t) => { + t.string("value", 1020).alter(); + }); + } +}