diff --git a/src/main/resources/archetype-resources/src/project-files/private-keys/.gitkeep b/src/main/resources/archetype-resources/src/project-files/.gitkeep similarity index 100% rename from src/main/resources/archetype-resources/src/project-files/private-keys/.gitkeep rename to src/main/resources/archetype-resources/src/project-files/.gitkeep diff --git a/src/main/resources/archetype-resources/src/sql-config/dbmigrate/100_CustomConfigurationDO.sql b/src/main/resources/archetype-resources/src/sql-config/dbmigrate/100_CustomConfigurationDO.sql index c954b6c..7b8877c 100644 --- a/src/main/resources/archetype-resources/src/sql-config/dbmigrate/100_CustomConfigurationDO.sql +++ b/src/main/resources/archetype-resources/src/sql-config/dbmigrate/100_CustomConfigurationDO.sql @@ -5,19 +5,19 @@ BEGIN CREATE TABLE oms."CustomConfigurationDO" ( id bigint, - "shop2SupplierRef" bigint, + "shop2SupplierRef" bigint NOT NULL, "configType" character varying(255) NOT NULL, - CONSTRAINT "CustomConfigurationDO_pkey" PRIMARY KEY (id), - CONSTRAINT "Shop2SupplierDO_fkey" FOREIGN KEY ("shop2SupplierRef") REFERENCES oms."Shop2SupplierDO" (id) ON UPDATE NO ACTION ON DELETE NO ACTION - ) - WITH ( - OIDS = FALSE - ) - ; + CONSTRAINT "CustomConfigurationDO_pk" PRIMARY KEY (id), + CONSTRAINT "Shop2SupplierDO_fk" FOREIGN KEY ("shop2SupplierRef") + REFERENCES oms."Shop2SupplierDO" (id) + ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT "CustomConfigurationDO_uk" UNIQUE ("shop2SupplierRef","configType") + + ); CREATE SEQUENCE oms."CustomConfigurationDO_id_seq"; + PERFORM admin.set_table_comment ('oms', 'CustomConfigurationDO','Contains custom property types for the Shop2SuppliersDO relations'); END IF; - IF false = admin.is_table('oms', 'CustomConfigurationDO_AV') THEN CREATE TABLE oms."CustomConfigurationDO_AV" ( @@ -26,14 +26,12 @@ BEGIN value text NOT NULL, CONSTRAINT pk_ref_key PRIMARY KEY ("customConfigurationRef", key), CONSTRAINT "fk_customConfigurationRef" FOREIGN KEY ("customConfigurationRef") - REFERENCES oms."CustomConfigurationDO" (id) MATCH SIMPLE + REFERENCES oms."CustomConfigurationDO" (id) ON UPDATE NO ACTION ON DELETE NO ACTION - ) - WITH ( - OIDS=FALSE ); - END IF; + PERFORM admin.set_table_comment ('oms', 'CustomConfigurationDO_AV','Contains custom property values for the Shop2SuppliersDO relations'); + END IF; END; -$Do$; +$Do$; \ No newline at end of file diff --git a/src/main/resources/archetype-resources/src/sql-config/dbmigrate/200_add_config_parameter.sql b/src/main/resources/archetype-resources/src/sql-config/dbmigrate/200_add_config_parameter.sql index e5bdce1..2f24f84 100644 --- a/src/main/resources/archetype-resources/src/sql-config/dbmigrate/200_add_config_parameter.sql +++ b/src/main/resources/archetype-resources/src/sql-config/dbmigrate/200_add_config_parameter.sql @@ -1,27 +1,34 @@ -DO $$ + + +-- DROP FUNCTION oms.add_config_parameter(bigint, character varying, character varying, character varying); +CREATE OR REPLACE FUNCTION oms.add_s2s_config_parameter( + p_shop2supplierref bigint, + p_configtype varchar, + p_key varchar, + p_value varchar) + RETURNS void AS +$$ + BEGIN - -- DROP FUNCTION oms.add_config_parameter(bigint, character varying, character varying, character varying); - CREATE OR REPLACE FUNCTION oms.add_config_parameter( - p_shop2supplierref bigint, - p_configtype character varying, - p_key character varying, - p_value character varying) - RETURNS void AS - $BODY$BEGIN - IF NOT EXISTS (SELECT 1 FROM oms."CustomConfigurationDO" where "shop2SupplierRef" = p_shop2supplierref and "configType" = p_configtype) THEN - INSERT INTO oms."CustomConfigurationDO" ("id", "shop2SupplierRef", "configType") - SELECT nextval('oms."CustomConfigurationDO_id_seq"'), p_shop2supplierref, p_configtype; - END IF; - IF p_key IS NOT NULL THEN - insert into oms."CustomConfigurationDO_AV" ("customConfigurationRef", key, value) - select (select id from oms."CustomConfigurationDO" where "shop2SupplierRef" = p_shop2supplierref and "configType" = p_configtype), p_key, p_value - ON CONFLICT ("customConfigurationRef", key) DO UPDATE SET value = p_value; - END IF; - END; - $BODY$ - LANGUAGE plpgsql VOLATILE - COST 100; + INSERT INTO oms."CustomConfigurationDO" ("id", "shop2SupplierRef", "configType") + SELECT nextval('oms."CustomConfigurationDO_id_seq"'), p_shop2supplierref, p_configtype + WHERE NOT EXISTS (select 1 FROM oms."CustomConfigurationDO" + where "shop2SupplierRef" = p_shop2supplierref and "configType" = p_configtype); + IF p_key IS NOT NULL THEN + INSERT INTO oms."CustomConfigurationDO_AV" ("customConfigurationRef", key, value) + SELECT (select id from oms."CustomConfigurationDO" where "shop2SupplierRef" = p_shop2supplierref and "configType" = p_configtype), p_key, p_value + ON CONFLICT ("customConfigurationRef", key) DO UPDATE SET value = p_value; + END IF; + END; -$$; \ No newline at end of file + +$$ +LANGUAGE plpgsql VOLATILE; + +comment on function oms.add_s2s_config_parameter( + p_shop2supplierref bigint, + p_configtype varchar, + p_key varchar, + p_value varchar) is 'add config values for a given Shop2SupplierDO / configType'; diff --git a/src/main/resources/archetype-resources/src/sql-config/dbmigrate/201_create_or_update_payment.sql b/src/main/resources/archetype-resources/src/sql-config/dbmigrate/201_create_or_update_payment.sql deleted file mode 100644 index d70c648..0000000 --- a/src/main/resources/archetype-resources/src/sql-config/dbmigrate/201_create_or_update_payment.sql +++ /dev/null @@ -1,48 +0,0 @@ -DO $$ -BEGIN - - -- Function: oms.create_or_update_payment(boolean, integer, character varying, bigint, bigint, smallint) - - -- DROP FUNCTION oms.create_or_update_payment(boolean, integer, character varying, bigint, bigint, smallint); - - CREATE OR REPLACE FUNCTION oms.create_or_update_payment( - p_active boolean, - p_paymentdefref integer, - p_shoppaymentname character varying, - p_shopref bigint, - p_paymentproviderref bigint, - p_payment2processstagedefref smallint) - RETURNS void AS - $BODY$BEGIN - - INSERT INTO oms."Shop2PaymentDefDO" - ("id", "active", "initOrderStateDefRef", "paymentDefRef", "shopPaymentName", "shopRef", - "safePayment", "payment2ProcessStageDefRef", "useAutomaticAuthorizationExtension", - "authizationDurationInDays", "timeForPaymentAllowed") - - SELECT nextval('oms."Shop2PaymentDefDO_id_seq"'), p_active, 2001, p_paymentdefref, p_shoppaymentname, p_shopref, - FALSE, p_payment2ProcessStageDefRef, FALSE, - NULL, NULL - ON CONFLICT ("paymentDefRef", "shopRef") DO UPDATE SET - active = EXCLUDED.active, "shopPaymentName" = EXCLUDED."shopPaymentName", - "payment2ProcessStageDefRef" = EXCLUDED."payment2ProcessStageDefRef" - ; - - IF p_paymentproviderref IS NULL THEN - DELETE FROM oms."Shop2PaymentProvider2PaymentDefDO" - WHERE "shopRef" = p_shopref AND "paymentDefRef" = p_paymentdefref; - ELSE - INSERT INTO oms."Shop2PaymentProvider2PaymentDefDO"(id, "shopRef", "paymentProviderRef", "paymentDefRef") - SELECT nextval('oms."Shop2PaymentProvider2PaymentDefDO_id_seq"'), p_shopref, p_paymentproviderref, p_paymentdefref - ON CONFLICT("shopRef", "paymentDefRef") DO UPDATE SET "paymentProviderRef" = EXCLUDED."paymentProviderRef"; - END IF; - - - END; - $BODY$ - LANGUAGE plpgsql VOLATILE - COST 100; - - -END; -$$; \ No newline at end of file diff --git a/src/main/resources/archetype-resources/src/sql-config/dbmigrate/202_create_or_update_shop.sql b/src/main/resources/archetype-resources/src/sql-config/dbmigrate/202_create_or_update_shop.sql deleted file mode 100644 index f2a754f..0000000 --- a/src/main/resources/archetype-resources/src/sql-config/dbmigrate/202_create_or_update_shop.sql +++ /dev/null @@ -1,91 +0,0 @@ -DO $$ -BEGIN - -- Function: oms.create_or_update_shop(bigint, boolean, integer, boolean, integer, boolean, character varying, integer, boolean, bigint, numeric, integer, character varying, character varying, boolean, bigint, bigint, boolean, boolean, character varying, boolean, character varying, boolean, character varying, character varying, character varying, character varying, smallint, smallint) - - CREATE OR REPLACE FUNCTION oms.create_or_update_shop( - p_id bigint, - p_active boolean, - p_availabilitytolerance integer, - p_isb2b boolean, - p_countrydefref integer, - p_maparticleid boolean, - p_name character varying, - p_orderoptimizedefref integer, - p_overwriteselectedsupplierallowed boolean, - p_parentref bigint, - p_parentorganization character varying, - p_returncharge numeric, - p_returndeadline integer, - p_shopname character varying, - p_shopordersequencename character varying, - p_singlearticleinfo boolean, - p_shopaddressref bigint, - p_shopordervalidationref bigint, - p_hassupplierprefix boolean, - p_hasinformshopreturn boolean, - p_internalshopname character varying, - p_shopusesomt boolean, - p_shopcustomersequencename character varying, - p_preferredsupplieronly boolean, - p_orderprocessingdelay character varying, - p_shopordersequencenumberformatstring character varying, - p_ordertokenvalidityduration character varying, - p_amountdaysforpaymentremindermailofprepaidorders smallint, - p_amountdaysforautocancellationofprepaidorders smallint, - p_isreservationwithdose boolean, - p_shoprmanumbersequencename character varying, - p_shoprmanumbersequenceformatstring character varying) - RETURNS void AS - $BODY$BEGIN - - INSERT INTO oms."ShopDO"( - "id", "active", "availabilityTolerance", "isB2B", --1 - "countryDefRef", "mapArticleId", "modificationDate", "name", --2 - "orderOptimizeDefRef", "overwriteSelectedSupplierAllowed", "parentRef", --3 - "returnDeadline", "shopName", "shopOrderSequenceName", --4 - "singleArticleInfo", "shopOrderValidationRef", --5 - "hasSupplierPrefix", "internalShopName", --6 - "shopCustomerSequenceName", "preferredSupplierOnly", --7 - "orderProcessingDelay", "shopOrderSequenceNumberFormatString", --8 - "orderTokenValidityDuration", --9 - "amountDaysForPaymentReminderMailOfPrepaidOrders", "amountDaysForAutoCancellationOfPrepaidOrders", "isReservationWithDOSE", --10 - "shopRMANumberSequenceName", "shopRMANumberSequenceFormatString") --11 - SELECT p_id, p_active, p_availabilityTolerance, p_isB2B, --1 - p_countryDefRef, p_mapArticleId, now(), p_name, --2 - p_orderOptimizeDefRef, p_overwriteSelectedSupplierAllowed, p_parentRef, --3 - p_returnDeadline, p_shopName, p_shopOrderSequenceName, --4 - p_singleArticleInfo, p_shopOrderValidationRef, --5 - p_hasSupplierPrefix, p_internalShopName, --6 - p_shopCustomerSequenceName, p_preferredSupplierOnly, --7 - p_orderProcessingDelay, p_shopOrderSequenceNumberFormatString, --8 - p_orderTokenValidityDuration, --9 - p_amountDaysForPaymentReminderMailOfPrepaidOrders, p_amountDaysForAutoCancellationOfPrepaidOrders, p_isreservationwithdose, --10 - p_shoprmanumbersequencename, p_shoprmanumbersequenceformatstring --11 - - ON CONFLICT (id) DO UPDATE SET - "active" = EXCLUDED."active", "availabilityTolerance" = EXCLUDED."availabilityTolerance", "isB2B" = EXCLUDED."isB2B", --1 - "countryDefRef" = EXCLUDED."countryDefRef", "mapArticleId" = EXCLUDED."mapArticleId", "modificationDate" = EXCLUDED."modificationDate", "name" = EXCLUDED."name", --2 - "orderOptimizeDefRef" = EXCLUDED."orderOptimizeDefRef", "overwriteSelectedSupplierAllowed" = EXCLUDED."overwriteSelectedSupplierAllowed", "parentRef" = EXCLUDED."parentRef", --3 - "returnDeadline" = EXCLUDED."returnDeadline", "shopName" = EXCLUDED."shopName", "shopOrderSequenceName" = EXCLUDED."shopOrderSequenceName", --4 - "singleArticleInfo" = EXCLUDED."singleArticleInfo", "shopOrderValidationRef" = EXCLUDED."shopOrderValidationRef", --5 - "hasSupplierPrefix" = EXCLUDED."hasSupplierPrefix", "internalShopName" = EXCLUDED."internalShopName", --6 - "shopCustomerSequenceName" = EXCLUDED."shopCustomerSequenceName", "preferredSupplierOnly" = EXCLUDED."preferredSupplierOnly", --7 - "orderProcessingDelay" = EXCLUDED."orderProcessingDelay", "shopOrderSequenceNumberFormatString" = EXCLUDED."shopOrderSequenceNumberFormatString", --8 - "orderTokenValidityDuration" = EXCLUDED."orderTokenValidityDuration", --9 - "amountDaysForPaymentReminderMailOfPrepaidOrders" = EXCLUDED."amountDaysForPaymentReminderMailOfPrepaidOrders", "amountDaysForAutoCancellationOfPrepaidOrders" = EXCLUDED."amountDaysForAutoCancellationOfPrepaidOrders", "isReservationWithDOSE" = EXCLUDED."isReservationWithDOSE", - "shopRMANumberSequenceName" = EXCLUDED."shopRMANumberSequenceName", "shopRMANumberSequenceFormatString" = EXCLUDED."shopRMANumberSequenceFormatString" - ; - IF p_parentRef IS NULL THEN - -- TODO adjust in new project or make configurable - PERFORM admin.set_parent_org(p_name, p_parentorganization); - END IF; - - - - END; - $BODY$ - LANGUAGE plpgsql VOLATILE - COST 100; - -END; -$$; \ No newline at end of file diff --git a/src/main/resources/archetype-resources/src/sql-config/dbmigrate/203_create_or_update_shop2supplier.sql b/src/main/resources/archetype-resources/src/sql-config/dbmigrate/203_create_or_update_shop2supplier.sql deleted file mode 100644 index 48c8a0c..0000000 --- a/src/main/resources/archetype-resources/src/sql-config/dbmigrate/203_create_or_update_shop2supplier.sql +++ /dev/null @@ -1,72 +0,0 @@ -DO $$ -BEGIN - - -- Function: oms.create_or_update_shop2supplier(boolean, bigint, bigint, character varying, character varying, bigint, boolean) - - -- DROP FUNCTION oms.create_or_update_shop2supplier(boolean, bigint, bigint, character varying, character varying, bigint, boolean, character varying); - - CREATE OR REPLACE FUNCTION oms.create_or_update_shop2supplier( - p_active boolean, - p_shopref bigint, - p_supplierref bigint, - p_shopsuppliername character varying, - p_suppliershopname character varying, - p_returncarrierref bigint, - p_usesupplierarticlenoasshoparticleno boolean, - p_shoparticlenoprefix character varying) - RETURNS void AS - $BODY$BEGIN - - INSERT INTO oms."Shop2SupplierDO"( - "id", - "active", - "modificationDate", - "reservationTimeInDays", - "shopAccount", - "shopPassword", - "shopSupplierName", - "splitShipmentAllowed", - "supplierAccount", - "supplierPassword", - "supplierShopName", - "shopRef", - "supplierRef", - "returnCarrierRef", - "useSupplierArticleNoAsShopArticleNo", - "shopArticleNoPrefix", - "stockReduceModel", - "supplierSupportsCOD") - SELECT nextval('oms."Shop2SupplierDO_id_seq"'), - p_active, - CURRENT_TIMESTAMP, - 0, - '', - '', - coalesce(p_shopSupplierName, (SELECT name FROM oms."SupplierDO" WHERE id = p_supplierRef)), - FALSE, - '', - '', - coalesce(p_supplierShopName, (SELECT name FROM oms."ShopDO" WHERE id = p_shopRef)), - p_shopRef, - p_supplierRef, - p_returnCarrierRef, - p_useSupplierArticleNoAsShopArticleNo, - p_shoparticlenoprefix, - 25, - true - - ON CONFLICT ("shopRef", "supplierRef") DO UPDATE SET - "shopSupplierName" = EXCLUDED."shopSupplierName", "supplierShopName" = EXCLUDED."supplierShopName", active = EXCLUDED.active, - "returnCarrierRef" = EXCLUDED."returnCarrierRef", "useSupplierArticleNoAsShopArticleNo" = EXCLUDED."useSupplierArticleNoAsShopArticleNo", - "shopArticleNoPrefix" = EXCLUDED."shopArticleNoPrefix", "stockReduceModel" = EXCLUDED."stockReduceModel" - ; - - - - END; - $BODY$ - LANGUAGE plpgsql VOLATILE - COST 100; - -END; -$$; \ No newline at end of file diff --git a/src/main/resources/archetype-resources/src/sql-config/dbmigrate/206_s2s_id.sql b/src/main/resources/archetype-resources/src/sql-config/dbmigrate/206_s2s_id.sql deleted file mode 100644 index b2cdc08..0000000 --- a/src/main/resources/archetype-resources/src/sql-config/dbmigrate/206_s2s_id.sql +++ /dev/null @@ -1,19 +0,0 @@ -DO $$ -BEGIN - --- Function: oms.s2s_id(bigint, bigint) - --- DROP FUNCTION oms.s2s_id(bigint, bigint); - -CREATE OR REPLACE FUNCTION oms.s2s_id( - p_shopref bigint, - p_supplierref bigint) - RETURNS bigint AS -$BODY$BEGIN - RETURN (SELECT id FROM oms."Shop2SupplierDO" WHERE "shopRef" = p_shopref AND "supplierRef" = p_supplierref); -END;$BODY$ - LANGUAGE plpgsql VOLATILE - COST 100; - -END; -$$; \ No newline at end of file diff --git a/src/main/resources/archetype-resources/src/sql-config/dbmigrate/207_upsert_eb_value.sql b/src/main/resources/archetype-resources/src/sql-config/dbmigrate/207_upsert_eb_value.sql deleted file mode 100644 index e28971a..0000000 --- a/src/main/resources/archetype-resources/src/sql-config/dbmigrate/207_upsert_eb_value.sql +++ /dev/null @@ -1,35 +0,0 @@ --- Function: oms.upsert_eb_value(bigint, text, bigint) - --- DROP FUNCTION oms.upsert_eb_value(bigint, text, bigint); - -CREATE OR REPLACE FUNCTION oms.upsert_eb_value( - p_executionbeankeydefref bigint, - p_parametervalue text, - p_communicationpartnerref bigint) - RETURNS void AS -$BODY$ - -DECLARE - ret int8; - -BEGIN - - SELECT id from oms."ExecutionBeanValueDO" where "communicationPartnerRef" = p_communicationPartnerRef and "executionBeanKeyDefRef" = p_executionBeanKeyDefRef - INTO ret; - - IF NOT EXISTS (SELECT NULL from oms."ExecutionBeanValueDO" where "communicationPartnerRef" = p_communicationPartnerRef and "executionBeanKeyDefRef" = p_executionBeanKeyDefRef) THEN - INSERT INTO oms."ExecutionBeanValueDO"(id, "executionBeanKeyDefRef", "parameterValue", "communicationPartnerRef") - SELECT nextval('oms."ExecutionBeanValueDO_id_seq"'), p_executionBeanKeyDefRef, p_parameterValue, p_communicationPartnerRef - ; - ELSE - UPDATE oms."ExecutionBeanValueDO" SET "parameterValue" = p_parameterValue - WHERE "executionBeanKeyDefRef" = p_executionBeanKeyDefRef AND "communicationPartnerRef" = p_communicationPartnerRef; - END IF; - - RETURN; - -END; - -$BODY$ - LANGUAGE plpgsql VOLATILE - COST 100; diff --git a/src/main/resources/archetype-resources/src/sql-config/dbmigrate/README.md b/src/main/resources/archetype-resources/src/sql-config/dbmigrate/README.md new file mode 100644 index 0000000..ce33738 --- /dev/null +++ b/src/main/resources/archetype-resources/src/sql-config/dbmigrate/README.md @@ -0,0 +1,4 @@ +### Example functions +In case you are missing the "old" PSQL helper functions please have a look at the blueprint project. + +See: [Github Repo iom-blueprint-project](https://github.com/intershop/iom-blueprint-project/tree/main/src/sql-config/dbmigrate) \ No newline at end of file