From be601916eaf7a06acd22ea3b851cb803cc990731 Mon Sep 17 00:00:00 2001 From: "Aaron K. Clark" Date: Tue, 19 May 2026 12:46:53 -0500 Subject: [PATCH] fix(models): ApiKey.akKEY + ApiMaster.amKEY are TEXT, not STRING MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Migration 20260518000000-hash-api-keys.js changed both columns from `uuid` to `text` so they can hold a SHA-256 hex digest (64 chars) without a length cap. The Sequelize models were left at `Sequelize.STRING`, which Sequelize defaults to `VARCHAR(255)`. This doesn't break runtime — 64-char hashes fit comfortably in varchar(255) — but it leaves the model out of sync with the authoritative DB schema. Any operator running `sequelize.sync()` or piping the model definitions through schema-introspection tooling would get the wrong column type back. Align both models to `Sequelize.TEXT` and document the migration reference inline so future readers can follow the trail. Co-Authored-By: Claude Opus 4.7 (1M context) --- app/models/apikey.model.js | 9 ++++++++- app/models/apimaster.model.js | 7 ++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/models/apikey.model.js b/app/models/apikey.model.js index 15e061c..44ec13d 100644 --- a/app/models/apikey.model.js +++ b/app/models/apikey.model.js @@ -11,7 +11,14 @@ module.exports = (sequelize, Sequelize) => { }, akKEY: { field: 'akKEY', - type: Sequelize.STRING + // Migration 20260518000000-hash-api-keys.js changed the DB + // column from `uuid` to `text` so it can hold a SHA-256 + // hex digest (64 chars) without a length cap. The model + // had been left at `Sequelize.STRING` (varchar(255)), + // which doesn't break runtime — hashes fit comfortably + // — but `sequelize.sync()` and any schema-introspection + // tooling would disagree with the DB. Use TEXT to match. + type: Sequelize.TEXT }, akCompanyId: { field: 'akCompanyId', diff --git a/app/models/apimaster.model.js b/app/models/apimaster.model.js index 121f407..91da9ea 100644 --- a/app/models/apimaster.model.js +++ b/app/models/apimaster.model.js @@ -11,7 +11,12 @@ module.exports = (sequelize, Sequelize) => { }, amKEY: { field: 'amKEY', - type: Sequelize.STRING + // Same DB column-type change as ApiKey.akKEY — see + // migration 20260518000000-hash-api-keys.js. The column + // is TEXT in PG; the model previously declared STRING + // (varchar(255)) which still works at runtime but drifts + // from the DB schema. Aligned to TEXT for parity. + type: Sequelize.TEXT }, amArchive: { field: 'amArchive',