From 7fbfd113894b68e30dfcf1759fb562725cebcba9 Mon Sep 17 00:00:00 2001 From: blam Date: Fri, 25 Oct 2024 13:54:04 +0200 Subject: [PATCH] chore: set as non-nullable after migration has completed Signed-off-by: blam --- .../20241024104700_add_entity_ref_to_final_entities.js | 7 +++++++ plugins/catalog-backend/src/database/tables.ts | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/catalog-backend/migrations/20241024104700_add_entity_ref_to_final_entities.js b/plugins/catalog-backend/migrations/20241024104700_add_entity_ref_to_final_entities.js index 3a7c98f425..b68bf1d7ef 100644 --- a/plugins/catalog-backend/migrations/20241024104700_add_entity_ref_to_final_entities.js +++ b/plugins/catalog-backend/migrations/20241024104700_add_entity_ref_to_final_entities.js @@ -38,6 +38,13 @@ exports.up = async function up(knex) { .where('r.entity_id', knex.raw('f.entity_id')), }) .table('final_entities as f'); + + // SQLite does not support ALTER COLUMN. + if (!knex.client.config.client.includes('sqlite3')) { + await knex.schema.alterTable('final_entities', table => { + table.text('entity_ref').notNullable().alter({ alterNullable: true }); + }); + } }; /** diff --git a/plugins/catalog-backend/src/database/tables.ts b/plugins/catalog-backend/src/database/tables.ts index df171ebb18..33e6250413 100644 --- a/plugins/catalog-backend/src/database/tables.ts +++ b/plugins/catalog-backend/src/database/tables.ts @@ -179,7 +179,7 @@ export type DbFinalEntitiesRow = { stitch_ticket: string; final_entity?: string; last_updated_at?: string | Date; - entity_ref?: string; + entity_ref: string; }; export type DbSearchRow = {