From 6a7a90536bf52ace69c0cc7429cabcbc35f8f403 Mon Sep 17 00:00:00 2001 From: Faruk AYDIN Date: Thu, 24 Oct 2024 15:14:41 +0200 Subject: [PATCH] feat: Make key field primary key for app config model --- ...241024130418_make_key_primary_for_app_configs.js | 13 +++++++++++++ packages/backend/src/models/app-config.js | 4 ++++ 2 files changed, 17 insertions(+) create mode 100644 packages/backend/src/db/migrations/20241024130418_make_key_primary_for_app_configs.js diff --git a/packages/backend/src/db/migrations/20241024130418_make_key_primary_for_app_configs.js b/packages/backend/src/db/migrations/20241024130418_make_key_primary_for_app_configs.js new file mode 100644 index 00000000..cae7f315 --- /dev/null +++ b/packages/backend/src/db/migrations/20241024130418_make_key_primary_for_app_configs.js @@ -0,0 +1,13 @@ +export async function up(knex) { + return knex.schema.alterTable('app_configs', function (table) { + table.dropPrimary(); + table.primary('key'); + }); +} + +export async function down(knex) { + return knex.schema.alterTable('app_configs', function (table) { + table.dropPrimary(); + table.primary('id'); + }); +} diff --git a/packages/backend/src/models/app-config.js b/packages/backend/src/models/app-config.js index 465600be..a4f3a0fb 100644 --- a/packages/backend/src/models/app-config.js +++ b/packages/backend/src/models/app-config.js @@ -5,6 +5,10 @@ import Base from './base.js'; class AppConfig extends Base { static tableName = 'app_configs'; + static get idColumn() { + return 'key'; + } + static jsonSchema = { type: 'object', required: ['key'],