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:
19
src/migrations/014_user_notes.js
Normal file
19
src/migrations/014_user_notes.js
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user