From 16498a7650943fb0a44a14575b879a663c9a1767 Mon Sep 17 00:00:00 2001 From: Martin Porwoll Date: Sat, 27 Dec 2025 20:51:11 +0000 Subject: [PATCH] fix: remove drizzle-kit push from auto-deploy to prevent data loss MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BREAKING: drizzle-kit push with --force can delete columns that exist in the database but not in the schema, causing data loss. Changes: - Remove automatic drizzle-kit push from deploy-production.sh - Add warnings to sync-schema.sh about potential data loss - Only use Payload migrations for safe schema changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- scripts/deploy-production.sh | 6 +++--- scripts/sync-schema.sh | 13 +++++++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/scripts/deploy-production.sh b/scripts/deploy-production.sh index 610cf6e..3cc83c1 100755 --- a/scripts/deploy-production.sh +++ b/scripts/deploy-production.sh @@ -255,9 +255,9 @@ if [ "$SKIP_MIGRATIONS" = false ]; then log "Running database migrations..." pnpm payload migrate || warn "No migrations to run or migration failed" - log "Syncing database schema with drizzle-kit..." - # Use drizzle-kit push to ensure schema is in sync (handles payload_locked_documents_rels etc.) - pnpm exec drizzle-kit push --config=drizzle.production.config.ts --force 2>/dev/null || warn "drizzle-kit push skipped or failed" + # WICHTIG: drizzle-kit push wurde aus dem automatischen Deployment entfernt + # um Datenverlust zu verhindern. Nur Payload-Migrationen sind sicher. + # Für manuelle Schema-Erweiterungen: ./scripts/sync-schema.sh --dry-run else warn "Skipping migrations (--skip-migrations)" fi diff --git a/scripts/sync-schema.sh b/scripts/sync-schema.sh index d5c1d18..70cb5a5 100755 --- a/scripts/sync-schema.sh +++ b/scripts/sync-schema.sh @@ -89,8 +89,17 @@ fi # Run schema sync echo "" -echo -e "${BLUE}Running drizzle-kit push...${NC}" -pnpm exec drizzle-kit push --config=drizzle.production.config.ts --force +echo -e "${RED}WARNUNG: drizzle-kit push kann Daten löschen wenn Spalten entfernt werden!${NC}" +echo -e "${YELLOW}Empfehlung: Nutze das fix-locked-docs-rels.sql Script für sichere Spalten-Hinzufügung.${NC}" +echo "" + +if [ "$FORCE" = true ]; then + echo -e "${BLUE}Running drizzle-kit push (FORCE mode - GEFÄHRLICH!)...${NC}" + pnpm exec drizzle-kit push --config=drizzle.production.config.ts --force +else + echo -e "${BLUE}Running drizzle-kit push (interactive mode)...${NC}" + pnpm exec drizzle-kit push --config=drizzle.production.config.ts +fi echo "" echo -e "${GREEN}Schema sync complete!${NC}"