-
Notifications
You must be signed in to change notification settings - Fork 495
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8706 from IQSS/8600-duplicate-template
8600 duplicate template
- Loading branch information
Showing
10 changed files
with
246 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
###Duplicate Templates in Database | ||
Prior to this release making a copy of a Dataset Template was creating two copies, one of which is visible in the dataverse, the other not being assigned | ||
a dataverse was invisible to the user (https://github.com/IQSS/dataverse/issues/8600). This release fixes the issue. | ||
|
||
If you would like to remove these orphan templates you may run the follwing script: | ||
|
||
https://github.com/IQSS/dataverse/raw/develop/scripts/issues/8600/delete_orphan_templates_8600.sh | ||
|
||
Also, admin APIs for finding and deleting templates have been added. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/bin/bash | ||
|
||
# begin config | ||
# PostgresQL credentials: | ||
# edit the following lines so that psql can talk to your database | ||
pg_host=localhost | ||
pg_port=5432 | ||
pg_user=dvnapp | ||
pg_db=dvndb | ||
#edit this line with the server for the api call to delete orphan templates | ||
SERVER=http://localhost:8080/api | ||
# you can leave the password blank, if Postgres is configured | ||
# to accept connections without auth: | ||
pg_pass= | ||
# psql executable - add full path, if necessary: | ||
PSQL_EXEC=psql | ||
|
||
# end config | ||
|
||
# check for orphan template : | ||
|
||
PG_QUERY_0="SELECT count(t.id) FROM template t WHERE dataverse_id is null;" | ||
PG_QUERY_1="SELECT t.id, ',' FROM template t WHERE dataverse_id is null;" | ||
|
||
PGPASSWORD=$pg_pass; export PGPASSWORD | ||
|
||
echo "Checking the total number of orphan templates in database..." | ||
|
||
NUM_TEMPLATES=`${PSQL_EXEC} -h ${pg_host} -U ${pg_user} -d ${pg_db} -tA -F ' ' -c "${PG_QUERY_0}"` | ||
if [ $? != 0 ] | ||
then | ||
echo "FAILED to execute psql! Check the credentials and try again?" | ||
echo "exiting..." | ||
echo | ||
echo "the command line that failed:" | ||
echo "${PSQL_EXEC} -h ${pg_host} -U ${pg_user} -d ${pg_db} -tA -F ' ' -c \"${PG_QUERY_0}\"" | ||
exit 1 | ||
fi | ||
|
||
echo $NUM_TEMPLATES total. | ||
echo | ||
|
||
|
||
TEMPLATE_ID=`${PSQL_EXEC} -h ${pg_host} -U ${pg_user} -d ${pg_db} -tA -F ' ' -c "${PG_QUERY_1}"` | ||
|
||
echo $TEMPLATE_ID to remove. | ||
|
||
|
||
${PSQL_EXEC} -h ${pg_host} -U ${pg_user} -d ${pg_db} -t -c "${PG_QUERY_1}" \ | ||
-t \ | ||
--field-separator ' ' \ | ||
--quiet \ | ||
| while read -a Record ; do | ||
id=${Record[0]} | ||
|
||
if [[ "x${id}" = "x" ]] | ||
then | ||
echo "nothing to do here" | ||
else | ||
curl -X DELETE $SERVER/admin/template/${id} | ||
echo "template ${id} deleted " | ||
fi | ||
|
||
done | ||
|
||
NUM_TEMPLATES=`${PSQL_EXEC} -h ${pg_host} -U ${pg_user} -d ${pg_db} -tA -F ' ' -c "${PG_QUERY_0}"` | ||
|
||
echo $NUM_TEMPLATES orphan templates remaining. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.