@@ -101,22 +101,16 @@ 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- -- Clean up duplicate entries before migration
105104 DO \\\$cleanup\\\$
106105 BEGIN
107- -- Clean up epersongroup2eperson duplicates
108106 IF EXISTS (SELECT 1 FROM information_schema.tables WHERE LOWER(table_name) = 'epersongroup2eperson') THEN
109- -- Delete duplicates, keeping only the first occurrence
110107 WITH ranked AS (
111108 SELECT ctid, row_number() OVER (PARTITION BY eperson_group_id, eperson_id ORDER BY ctid) AS rn
112109 FROM epersongroup2eperson
113110 )
114111 DELETE FROM epersongroup2eperson
115- WHERE ctid IN (
116- SELECT ctid FROM ranked WHERE rn > 1
117- );
112+ WHERE ctid IN (SELECT ctid FROM ranked WHERE rn > 1);
118113
119- -- Verify cleanup worked
120114 IF EXISTS (
121115 SELECT 1 FROM (
122116 SELECT eperson_group_id, eperson_id, COUNT(*)
@@ -125,42 +119,9 @@ jobs:
125119 HAVING COUNT(*) > 1
126120 ) remaining_dups
127121 ) THEN
128- RAISE EXCEPTION 'Failed to clean all duplicates from epersongroup2eperson';
122+ RAISE EXCEPTION 'Failed to clean duplicates from epersongroup2eperson';
129123 END IF;
130124 END IF;
131-
132- -- Clean other potential duplicate tables
133- IF EXISTS (SELECT 1 FROM information_schema.tables WHERE LOWER(table_name) = 'epersongroup2workspaceitem') THEN
134- WITH ranked AS (
135- SELECT ctid, row_number() OVER (PARTITION BY eperson_group_id, workspace_item_id ORDER BY ctid) AS rn
136- FROM epersongroup2workspaceitem
137- )
138- DELETE FROM epersongroup2workspaceitem WHERE ctid IN (SELECT ctid FROM ranked WHERE rn > 1);
139- END IF;
140-
141- IF EXISTS (SELECT 1 FROM information_schema.tables WHERE LOWER(table_name) = 'collection2item') THEN
142- WITH ranked AS (
143- SELECT ctid, row_number() OVER (PARTITION BY collection_id, item_id ORDER BY ctid) AS rn
144- FROM collection2item
145- )
146- DELETE FROM collection2item WHERE ctid IN (SELECT ctid FROM ranked WHERE rn > 1);
147- END IF;
148-
149- IF EXISTS (SELECT 1 FROM information_schema.tables WHERE LOWER(table_name) = 'community2collection') THEN
150- WITH ranked AS (
151- SELECT ctid, row_number() OVER (PARTITION BY community_id, collection_id ORDER BY ctid) AS rn
152- FROM community2collection
153- )
154- DELETE FROM community2collection WHERE ctid IN (SELECT ctid FROM ranked WHERE rn > 1);
155- END IF;
156-
157- IF EXISTS (SELECT 1 FROM information_schema.tables WHERE LOWER(table_name) = 'community2community') THEN
158- WITH ranked AS (
159- SELECT ctid, row_number() OVER (PARTITION BY parent_comm_id, child_comm_id ORDER BY ctid) AS rn
160- FROM community2community
161- )
162- DELETE FROM community2community WHERE ctid IN (SELECT ctid FROM ranked WHERE rn > 1);
163- END IF;
164125 END \\\$cleanup\\\$;
165126 \" &&
166127 rm /tmp/$FNAME
0 commit comments