fix(db): migration 014 — add users.notes column (Next.js admin Prisma requires it)

- prod DB was missing users.notes → /api/users/bulk 500 (Prisma P2022)
- Applied to prod; users + lead relations now load correctly
This commit is contained in:
NW
2026-08-08 13:26:52 +01:00
parent c7a4463ac4
commit 9bc0bffac7
2 changed files with 20 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
import logger from '../utils/logger.js';
// Migration 014: add notes column to users (required by Next.js admin Prisma schema)
export default async function migration014(db, checkColumnExists) {
if (await checkColumnExists('users', 'notes')) {
logger.info('Migration 014: notes column already exists, skipping');
return;
}
await db.runAsync('BEGIN TRANSACTION');
try {
await db.runAsync(`ALTER TABLE users ADD COLUMN notes TEXT`);
await db.runAsync('COMMIT');
logger.info('Migration 014: Added notes column to users table');
} catch (e) {
await db.runAsync('ROLLBACK');
throw e;
}
}

View File

@@ -48,6 +48,7 @@ export async function runMigrations() {
(await import('./011_active_flags.js')).default, (await import('./011_active_flags.js')).default,
(await import('./012_fix_typos.js')).default, (await import('./012_fix_typos.js')).default,
(await import('./013_ai_features.js')).default, (await import('./013_ai_features.js')).default,
(await import('./014_user_notes.js')).default,
]; ];
for (let i = currentVersion; i < migrations.length; i++) { for (let i = currentVersion; i < migrations.length; i++) {