From c45bd3bb0fba936a293c8ce8a572e1db00d28833 Mon Sep 17 00:00:00 2001 From: Accusys Date: Thu, 14 May 2026 14:45:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20deploy=20script=20schema=20integrity=20?= =?UTF-8?q?=E2=80=94=20normalize=20COPY=20schema=20prefix=20via=20sed=20+?= =?UTF-8?q?=20drop=20identities=5Fname=5Fkey=20constraint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/deploy_package.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/scripts/deploy_package.sh b/scripts/deploy_package.sh index 4d40527..1e53ca2 100644 --- a/scripts/deploy_package.sh +++ b/scripts/deploy_package.sh @@ -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"