Dear Helix and Terry,

I am running this dspace instance in a windows environment so I just 
manually run the SQL commands from your script and it worked. Running the 
migrate command though I encountered another error this time from the table 
group2group (Message : ERROR: could not create unique index 
"group2group_pkey" Detail: Key (parent_id, 
child_id)=(e226cfe7-385e-4547-977e-3de9e16a4b3e, 
a1ef01c6-0420-47de-ba1c-50c695644bcf) 
is duplicated., so I just run your SQL again but this time replacing 
eperson_group_id and eperson_id by parent_id and child_id respectively. Now 
when I run the migrate command, it is successful.

Thank you so much for this!

Best regards,
euler

On Thursday, November 10, 2016 at 7:49:41 AM UTC+8, helix84 wrote:
>
> Same script without mangled newlines:
>
> cleanup_eperson.sh:
>
> #!/bin/sh
>
> total=`psql -A -t -c "SELECT count(1) FROM epersongroup2eperson;"`
> distinct=`psql -A -t -c "SELECT count(DISTINCT (eperson_group_id, 
> eperson_id)) FROM epersongroup2eperson;"`
>
> # for testing only:
> #total=$(($total+1))
>
> echo $total
> echo $distinct
>
> if [ "$total" -gt "$distinct" ] ; then
>
>         echo "Cleaning up..." | mail -s "digilib eperson table cleanup 
> ($total/$distinct)" [email protected] <javascript:>
>
>         report=`psql 2>&1 <<THE_END
>                       SELECT MIN(ctid) as ctid, eperson_group_id, 
> eperson_id
>                         FROM epersongroup2eperson
>                         GROUP BY eperson_group_id, eperson_id HAVING 
> COUNT(*) > 1;
> THE_END`
>
>         # perform the cleanup
>         # capture the output and running time
>         cleanuptime=`time psql 2>&1 <<THE_END
>                 DELETE FROM epersongroup2eperson a USING (
>                       SELECT MIN(ctid) as ctid, eperson_group_id, 
> eperson_id
>                         FROM epersongroup2eperson
>                         GROUP BY eperson_group_id, eperson_id HAVING 
> COUNT(*) > 1
>                       ) b
>                 WHERE a.eperson_group_id = b.eperson_group_id
>                 AND a.eperson_id = b.eperson_id
>                 AND a.ctid <> b.ctid;
> THE_END`
>
>         # check again and report the status by email
>         out=`psql <<THE_END
>                 SELECT count(1) FROM epersongroup2eperson;
>                 SELECT count(DISTINCT (eperson_group_id, eperson_id)) FROM 
> epersongroup2eperson;
> THE_END`
>         echo "$report\n\n\n\n$cleanuptime\n\n$out" | mail -s "digilib 
> eperson table cleanup complete" [email protected] <javascript:>
>
>         echo "email sent: $out"
>
> else
>         echo "" | mail -s "digilib eperson table clean" 
> [email protected] <javascript:>
> fi
>
>
>
>
> Regards,
> ~~helix84
>
> Compulsory reading: DSpace Mailing List Etiquette
> https://wiki.duraspace.org/display/DSPACE/Mailing+List+Etiquette
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"DSpace Technical Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/dspace-tech.
For more options, visit https://groups.google.com/d/optout.

Reply via email to