fix: deploy.sh normalizes schema prefix in data.sql too (format normalization)

This commit is contained in:
Accusys
2026-05-14 14:46:53 +08:00
parent df47ed1417
commit 2c4e32f14a

View File

@@ -108,11 +108,16 @@ echo " ✅ Cleared existing data for $UUID"
# 3. Import each table file in dependency order (FK constraints)
echo "[3/9] Normalizing schema prefix and importing DB data..."
# Normalize COPY schema prefix: dev. → ${SCHEMA}. so it matches target schema
# Normalize COPY schema prefix in per-table files and data.sql
if [ "${SCHEMA}" != "dev" ]; then
for f in "$DIR"/sql/dev_*.sql; do
sed -i '' "s/COPY dev\./COPY ${SCHEMA}./g" "$f"
done
# Also normalize data.sql if present (full dump format)
if [ -f "$DIR/data.sql" ]; then
sed -i '' "s/COPY dev\./COPY ${SCHEMA}./g" "$DIR/data.sql"
sed -i '' "s/Schema: dev/Schema: ${SCHEMA}/g" "$DIR/data.sql"
fi
echo " Schema prefix normalized: dev. → ${SCHEMA}."
fi
IMPORT_ORDER=(