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

@@ -4,6 +4,7 @@ import { auth } from '@/auth'
import { titleSuggestionService } from '@/lib/ai/services/title-suggestion.service'
import { prisma } from '@/lib/prisma'
import { revalidatePath } from 'next/cache'
import { createNoteHistorySnapshot, isNoteHistoryEnabledForUser } from '@/lib/note-history'
export interface GenerateTitlesResponse {
suggestions: Array<{
@@ -82,6 +83,19 @@ export async function applyTitleSuggestion(
}
})
try {
const historyEnabled = await isNoteHistoryEnabledForUser(session.user.id)
if (historyEnabled) {
await createNoteHistorySnapshot({
noteId,
userId: session.user.id,
reason: 'title-suggestion',
})
}
} catch (snapshotError) {
console.error('[HISTORY] Failed to create snapshot after title suggestion:', snapshotError)
}
revalidatePath('/')
revalidatePath(`/note/${noteId}`)
} catch (error) {