fix: remove drizzle-kit push from auto-deploy to prevent data loss

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 <noreply@anthropic.com>
This commit is contained in:
Martin Porwoll 2025-12-27 20:51:11 +00:00
parent 9e433315e5
commit 16498a7650
2 changed files with 14 additions and 5 deletions

View file

@ -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

View file

@ -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}"