feat: robust automatic DB migration for Docker deployments
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 44s

Backup before migration (pg_dump/SQLite copy), DB connection wait with
retries, idempotent prisma migrate deploy, old backup cleanup (keep 5),
and server refuses to start if migration fails.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-04-28 21:30:45 +02:00
parent 69ea064ca8
commit 39c705592a
30 changed files with 181 additions and 8064 deletions

View File

@@ -2,6 +2,7 @@ import { NextRequest, NextResponse } from 'next/server'
import prisma from '@/lib/prisma'
import { auth } from '@/auth'
import { reconcileLabelsAfterNoteMove } from '@/app/actions/notes'
import { createNoteHistorySnapshot, isNoteHistoryEnabledForUser } from '@/lib/note-history'
// POST /api/notes/[id]/move - Move a note to a notebook (or to Inbox)
export async function POST(
@@ -76,6 +77,19 @@ export async function POST(
await reconcileLabelsAfterNoteMove(id, targetNotebookId)
try {
const historyEnabled = await isNoteHistoryEnabledForUser(session.user.id)
if (historyEnabled) {
await createNoteHistorySnapshot({
noteId: id,
userId: session.user.id,
reason: 'move-notebook',
})
}
} catch (snapshotError) {
console.error('[HISTORY] Failed to create snapshot after notebook move:', snapshotError)
}
// No revalidatePath('/') here — the client-side triggerRefresh() in
// notebooks-context.tsx handles the refresh. Avoiding server-side
// revalidation prevents a double-refresh (server + client).