fix: deploy script schema integrity — normalize COPY schema prefix via sed + drop identities_name_key constraint
This commit is contained in:
@@ -95,11 +95,26 @@ echo "[2/9] Pre-cleaning existing data for this file..."
|
||||
DELETE FROM ${P}chunk_vectors WHERE uuid = '$UUID';
|
||||
DELETE FROM ${P}chunk WHERE file_uuid = '$UUID';
|
||||
DELETE FROM ${P}videos WHERE file_uuid = '$UUID';
|
||||
-- Drop legacy constraint that conflicts with global identity re-import
|
||||
DO \$\$
|
||||
BEGIN
|
||||
IF EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'identities_name_key') THEN
|
||||
ALTER TABLE ${P}identities DROP CONSTRAINT identities_name_key;
|
||||
END IF;
|
||||
END
|
||||
\$\$;
|
||||
EOSQL
|
||||
echo " ✅ Cleared existing data for $UUID"
|
||||
|
||||
# 3. Import each table file in dependency order (FK constraints)
|
||||
echo "[3/9] Importing DB data (per-table)..."
|
||||
echo "[3/9] Normalizing schema prefix and importing DB data..."
|
||||
# Normalize COPY schema prefix: dev. → ${SCHEMA}. so it matches target schema
|
||||
if [ "${SCHEMA}" != "dev" ]; then
|
||||
for f in "$DIR"/sql/dev_*.sql; do
|
||||
sed -i '' "s/COPY dev\./COPY ${SCHEMA}./g" "$f"
|
||||
done
|
||||
echo " Schema prefix normalized: dev. → ${SCHEMA}."
|
||||
fi
|
||||
IMPORT_ORDER=(
|
||||
"sql/dev_videos.sql"
|
||||
"sql/dev_chunk.sql"
|
||||
|
||||
Reference in New Issue
Block a user