diff --git a/scripts/sync_from_prod.sh b/scripts/sync_from_prod.sh index f0ce63d..37f1d04 100755 --- a/scripts/sync_from_prod.sh +++ b/scripts/sync_from_prod.sh @@ -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" # 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..." 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" # Verify dump file is not empty