diff --git a/deltaScripts/14.2.1/registryQueryUpdate/updateQueriesSql.sql b/deltaScripts/14.2.1/registryQueryUpdate/updateQueriesSql.sql index c03c6ff67f..8051956493 100644 --- a/deltaScripts/14.2.1/registryQueryUpdate/updateQueriesSql.sql +++ b/deltaScripts/14.2.1/registryQueryUpdate/updateQueriesSql.sql @@ -1,26 +1,66 @@ -delete from ebxml.taxonomyelementtype_classificationnode where classificationnode_id='urn:oasis:names:tc:ebxml-regrep:QueryLanguage:SPARQL'; -delete from ebxml.classificationnode where id= 'urn:oasis:names:tc:ebxml-regrep:QueryLanguage:SPARQL'; +CREATE FUNCTION taxonomyelementtype_classificationnode_update() RETURNS void AS $$ + DECLARE + t bool; + BEGIN + SELECT EXISTS( + SELECT * FROM information_schema.tables + WHERE + table_schema = 'ebxml' AND + table_name = 'taxonomyelementtype_classificationnode' +) into t; + IF + t ='t' + THEN + delete from ebxml.taxonomyelementtype_classificationnode where classificationnode_id='urn:oasis:names:tc:ebxml-regrep:QueryLanguage:SPARQL'; + delete from ebxml.taxonomyelementtype_classificationnode where classificationnode_id='urn:oasis:names:tc:ebxml-regrep:QueryLanguage:SQL-92'; + delete from ebxml.taxonomyelementtype_classificationnode where classificationnode_id='urn:oasis:names:tc:ebxml-regrep:QueryLanguage:XQuery'; + delete from ebxml.taxonomyelementtype_classificationnode where classificationnode_id='urn:oasis:names:tc:ebxml-regrep:QueryLanguage:EJBQL'; + delete from ebxml.taxonomyelementtype_classificationnode where classificationnode_id='urn:oasis:names:tc:ebxml-regrep:query:ExportObject'; + delete from ebxml.taxonomyelementtype_classificationnode where classificationnode_id='urn:oasis:names:tc:ebxml-regrep:query:FindAllMyObjects'; + delete from ebxml.taxonomyelementtype_classificationnode where classificationnode_id='urn:oasis:names:tc:ebxml-regrep:query:ExtrinsicObjectQuery'; + INSERT INTO ebxml.taxonomyelementtype_classificationnode(taxonomyelementtype_id,classificationnode_id) + VALUES('urn:oasis:names:tc:ebxml-regrep:classificationScheme:QueryLanguage','urn:oasis:names:tc:ebxml-regrep:QueryLanguage:HQL'); + RAISE NOTICE 'updated ebxml.taxonomyelementtype_classificationnode table, success!'; + ELSE + RAISE NOTICE 'Table ebxml.taxonomyelementtype_classificationnode does not exist, skipping!'; + END IF; + END; +$$ LANGUAGE plpgsql; -delete from ebxml.taxonomyelementtype_classificationnode where classificationnode_id='urn:oasis:names:tc:ebxml-regrep:QueryLanguage:SQL-92'; -delete from ebxml.classificationnode where id= 'urn:oasis:names:tc:ebxml-regrep:QueryLanguage:SQL-92'; +CREATE FUNCTION classificationnode_update() RETURNS void AS $$ + DECLARE + t bool; + BEGIN + SELECT EXISTS( + SELECT * FROM information_schema.tables + WHERE + table_schema = 'ebxml' AND + table_name = 'classificationnode' +) into t; + IF + t ='t' + THEN + delete from where id= 'urn:oasis:names:tc:ebxml-regrep:QueryLanguage:SPARQL'; + delete from ebxml.classificationnode where id= 'urn:oasis:names:tc:ebxml-regrep:QueryLanguage:SQL-92'; + delete from ebxml.classificationnode where id= 'urn:oasis:names:tc:ebxml-regrep:QueryLanguage:XQuery'; + delete from ebxml.classificationnode where id= 'urn:oasis:names:tc:ebxml-regrep:QueryLanguage:EJBQL'; + delete from ebxml.classificationnode where id= 'urn:oasis:names:tc:ebxml-regrep:query:ExportObject'; + delete from ebxml.classificationnode where id= 'urn:oasis:names:tc:ebxml-regrep:query:FindAllMyObjects'; + delete from ebxml.classificationnode where id= 'urn:oasis:names:tc:ebxml-regrep:query:ExtrinsicObjectQuery'; + INSERT INTO ebxml.classificationnode (id,lid,objecttype,owner,versionname,code,parent,path) + VALUES ('urn:oasis:names:tc:ebxml-regrep:QueryLanguage:HQL','urn:oasis:names:tc:ebxml-regrep:QueryLanguage:HQL', + 'urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:ClassificationNode','NCF','1','HQL', + 'urn:oasis:names:tc:ebxml-regrep:classificationScheme:QueryLanguage','/urn:oasis:names:tc:ebxml-regrep:classificationScheme:QueryLanguage/HQL'); + RAISE NOTICE 'updated ebxml.classificationnode table, success!'; + ELSE + RAISE NOTICE 'Table ebxml.classificationnode does not exist, skipping!'; + END IF; + END; +$$ LANGUAGE plpgsql; -delete from ebxml.taxonomyelementtype_classificationnode where classificationnode_id='urn:oasis:names:tc:ebxml-regrep:QueryLanguage:XQuery'; -delete from ebxml.classificationnode where id= 'urn:oasis:names:tc:ebxml-regrep:QueryLanguage:XQuery'; +select taxonomyelementtype_classificationnode_update(); +select classificationnode_update(); -delete from ebxml.taxonomyelementtype_classificationnode where classificationnode_id='urn:oasis:names:tc:ebxml-regrep:QueryLanguage:EJBQL'; -delete from ebxml.classificationnode where id= 'urn:oasis:names:tc:ebxml-regrep:QueryLanguage:EJBQL'; +DROP FUNCTION taxonomyelementtype_classificationnode_update(); +DROP FUNCTION classificationnode_update(); -INSERT INTO ebxml.classificationnode (id,lid,objecttype,owner,versionname,code,parent,path) VALUES -('urn:oasis:names:tc:ebxml-regrep:QueryLanguage:HQL','urn:oasis:names:tc:ebxml-regrep:QueryLanguage:HQL', -'urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:ClassificationNode','NCF','1','HQL', -'urn:oasis:names:tc:ebxml-regrep:classificationScheme:QueryLanguage','/urn:oasis:names:tc:ebxml-regrep:classificationScheme:QueryLanguage/HQL'); -INSERT INTO ebxml.taxonomyelementtype_classificationnode(taxonomyelementtype_id,classificationnode_id) VALUES('urn:oasis:names:tc:ebxml-regrep:classificationScheme:QueryLanguage','urn:oasis:names:tc:ebxml-regrep:QueryLanguage:HQL'); - -delete from ebxml.taxonomyelementtype_classificationnode where classificationnode_id='urn:oasis:names:tc:ebxml-regrep:query:ExportObject'; -delete from ebxml.classificationnode where id= 'urn:oasis:names:tc:ebxml-regrep:query:ExportObject'; - -delete from ebxml.taxonomyelementtype_classificationnode where classificationnode_id='urn:oasis:names:tc:ebxml-regrep:query:FindAllMyObjects'; -delete from ebxml.classificationnode where id= 'urn:oasis:names:tc:ebxml-regrep:query:FindAllMyObjects'; - -delete from ebxml.taxonomyelementtype_classificationnode where classificationnode_id='urn:oasis:names:tc:ebxml-regrep:query:ExtrinsicObjectQuery'; -delete from ebxml.classificationnode where id= 'urn:oasis:names:tc:ebxml-regrep:query:ExtrinsicObjectQuery'; diff --git a/deltaScripts/14.2.1/updateMadisTableConstraint.sql b/deltaScripts/14.2.1/updateMadisTableConstraint.sql index 68ead33a90..a4d2b92490 100644 --- a/deltaScripts/14.2.1/updateMadisTableConstraint.sql +++ b/deltaScripts/14.2.1/updateMadisTableConstraint.sql @@ -1,3 +1,3 @@ -alter table madis drop constraint madis_location_reftime_provider_subprovider_restriction_key; +alter table if exists madis drop constraint madis_location_reftime_provider_subprovider_restriction_key; +alter table if exists madis add CONSTRAINT madis_latitude_longitude_stationid_reftime_provider_subprovider UNIQUE (latitude, longitude, stationid, reftime, provider, subprovider, restriction) -alter table madis add constraint madis_location_stationid_reftime_provider_subprovider_restr_key UNIQUE (location, stationid, reftime, provider, subprovider, restriction)