CLAUDE: Add --clean flag to production database sync

Use pg_dump --clean to drop existing objects before recreating them,
ensuring a cleaner sync without conflicts from existing objects.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Cal Corum 2025-10-23 16:52:42 -05:00
parent 76ce9f3c47
commit b39066e06d

View File

@ -41,9 +41,10 @@ echo "Testing local database connection..."
pg_isready -h sba_postgres -U ${SBA_DB_USER} -d ${SBA_DATABASE} || error_exit "Local database is not ready" pg_isready -h sba_postgres -U ${SBA_DB_USER} -d ${SBA_DATABASE} || error_exit "Local database is not ready"
# Create dump from production server first (safer than direct pipe) # Create dump from production server first (safer than direct pipe)
# Using --clean to drop existing objects before recreating them
echo "Creating dump from production server..." echo "Creating dump from production server..."
ssh -o StrictHostKeyChecking=no akamai \ ssh -o StrictHostKeyChecking=no akamai \
"cd container-data/sba-database && source .env && docker exec -e PGPASSWORD=\$SBA_DB_USER_PASSWORD sba_postgres pg_dump -U \$SBA_DB_USER -d \$SBA_DATABASE" \ "cd container-data/sba-database && source .env && docker exec -e PGPASSWORD=\$SBA_DB_USER_PASSWORD sba_postgres pg_dump --clean -U \$SBA_DB_USER -d \$SBA_DATABASE" \
> /tmp/prod_dump.sql || error_exit "Failed to create production database dump" > /tmp/prod_dump.sql || error_exit "Failed to create production database dump"
# Verify dump file is not empty # Verify dump file is not empty