From f9ffa276f89c78272612dc637f7526c647bc1c08 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Thu, 14 Feb 2019 15:07:36 -0500 Subject: [PATCH] fix for case when there is no shoulder --- scripts/database/upgrades/upgrade_v4.8.6_to_v4.9.sql | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/scripts/database/upgrades/upgrade_v4.8.6_to_v4.9.sql b/scripts/database/upgrades/upgrade_v4.8.6_to_v4.9.sql index 1158b2942a8..5335c9ae270 100644 --- a/scripts/database/upgrades/upgrade_v4.8.6_to_v4.9.sql +++ b/scripts/database/upgrades/upgrade_v4.8.6_to_v4.9.sql @@ -62,12 +62,11 @@ ALTER TABLE dvobject DROP COLUMN doiseparator; --Add new setting into content for shoulder INSERT INTO setting(name, content) -VALUES (':Shoulder', (SELECT substring(content, strpos(content,'/')+1) || '/' from setting where name = ':Authority')); +SELECT ':Shoulder', substring(content, strpos(content,'/')+1) || '/' from setting where name = ':Authority' and strpos(content,'/')>0; - --strip shoulder from authority setting - UPDATE setting - SET content=(SELECT substring(content from 0 for strpos(content,'/')) - FROM setting - WHERE name=':Authority' and strpos(content,'/')>0) where name=':Authority'; +--strip shoulder from authority setting if the shoulder exists +UPDATE setting +SET content= case when (strpos(content,'/')>0) then substring(content from 0 for strpos(content,'/')) +else content end where name=':Authority'; update datasetfieldtype set displayformat = '#VALUE' where name in ('alternativeURL', 'keywordVocabularyURI', 'topicClassVocabURI', 'publicationURL', 'producerURL', 'distributorURL');