diff --git a/server/api/models/User.js b/server/api/models/User.js index f1089a77..7aa20e93 100755 --- a/server/api/models/User.js +++ b/server/api/models/User.js @@ -204,6 +204,19 @@ module.exports = { type: 'ref', columnName: 'password_changed_at', }, + apiKeyPrefix: { + type: 'string', + columnName: 'api_key_prefix', + isNotEmptyString: true, + allowNull: true, + unique: true, + }, + apiKeyHash: { + type: 'string', + columnName: 'api_key_hash', + isNotEmptyString: true, + allowNull: true, + }, // ╔═╗╔╦╗╔╗ ╔═╗╔╦╗╔═╗ // ║╣ ║║║╠╩╗║╣ ║║╚═╗ diff --git a/server/db/migrations/20250712223423_add_api_key_fields_to_user.js b/server/db/migrations/20250712223423_add_api_key_fields_to_user.js new file mode 100644 index 00000000..96629b48 --- /dev/null +++ b/server/db/migrations/20250712223423_add_api_key_fields_to_user.js @@ -0,0 +1,19 @@ +/*! + * Copyright (c) 2024 PLANKA Software GmbH + * Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md + */ + +exports.up = (knex) => { + return knex.schema.alterTable('user_account', (table) => { + table.string('api_key_prefix', 255).unique().nullable(); + table.string('api_key_hash', 255).nullable(); + }); +}; + +exports.down = (knex) => { + return knex.schema.alterTable('user_account', (table) => { + table.dropUnique(['api_key_prefix']); + table.dropColumn('api_key_prefix'); + table.dropColumn('api_key_hash'); + }); +};