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');