@@ -101,26 +101,11 @@ jobs:
101101 psql -p 10563 -U dspace -d dspace -f /tmp/$FNAME &&
102102 psql -p 10563 -U dspace -d dspace -c 'CREATE EXTENSION IF NOT EXISTS pgcrypto;' &&
103103 psql -p 10563 -U dspace -d dspace -c \"
104- -- Comprehensive cleanup of duplicate entries before migration
105-
106- -- First, let's check what tables actually exist and their names
107- \\\\echo 'Checking existing tables...';
108-
109- -- Clean up epersongroup2eperson duplicates (case variations)
104+ -- Clean up duplicate entries before migration
110105 DO \\\$cleanup\\\$
111106 BEGIN
112- -- Try different case variations of the table name
107+ -- Clean up epersongroup2eperson duplicates
113108 IF EXISTS (SELECT 1 FROM information_schema.tables WHERE LOWER(table_name) = 'epersongroup2eperson') THEN
114- \\\\echo 'Cleaning epersongroup2eperson duplicates...';
115-
116- -- First show how many duplicates we have
117- PERFORM (SELECT COUNT(*) FROM (
118- SELECT eperson_group_id, eperson_id, COUNT(*)
119- FROM epersongroup2eperson
120- GROUP BY eperson_group_id, eperson_id
121- HAVING COUNT(*) > 1
122- ) dups);
123-
124109 -- Delete duplicates, keeping only the first occurrence
125110 WITH ranked AS (
126111 SELECT ctid, row_number() OVER (PARTITION BY eperson_group_id, eperson_id ORDER BY ctid) AS rn
@@ -142,17 +127,15 @@ jobs:
142127 ) THEN
143128 RAISE EXCEPTION 'Failed to clean all duplicates from epersongroup2eperson';
144129 END IF;
145-
146- \\\\echo 'epersongroup2eperson cleanup completed successfully';
147130 END IF;
148131
149- -- Check for other possible table name variations
150- IF EXISTS (SELECT 1 FROM information_schema.tables WHERE LOWER(table_name) = 'epersongroup2workspace ') THEN
132+ -- Clean other potential duplicate tables
133+ IF EXISTS (SELECT 1 FROM information_schema.tables WHERE LOWER(table_name) = 'epersongroup2workspaceitem ') THEN
151134 WITH ranked AS (
152135 SELECT ctid, row_number() OVER (PARTITION BY eperson_group_id, workspace_item_id ORDER BY ctid) AS rn
153- FROM epersongroup2workspace
136+ FROM epersongroup2workspaceitem
154137 )
155- DELETE FROM epersongroup2workspace WHERE ctid IN (SELECT ctid FROM ranked WHERE rn > 1);
138+ DELETE FROM epersongroup2workspaceitem WHERE ctid IN (SELECT ctid FROM ranked WHERE rn > 1);
156139 END IF;
157140
158141 IF EXISTS (SELECT 1 FROM information_schema.tables WHERE LOWER(table_name) = 'collection2item') THEN
@@ -179,8 +162,6 @@ jobs:
179162 DELETE FROM community2community WHERE ctid IN (SELECT ctid FROM ranked WHERE rn > 1);
180163 END IF;
181164 END \\\$cleanup\\\$;
182-
183- \\\\echo 'All duplicate cleanup completed';
184165 \" &&
185166 rm /tmp/$FNAME
186167 "
0 commit comments