diff --git a/app/services/data/tear-down/water-schema.service.js b/app/services/data/tear-down/water-schema.service.js index 7bfdabdf9a..16c65ed867 100644 --- a/app/services/data/tear-down/water-schema.service.js +++ b/app/services/data/tear-down/water-schema.service.js @@ -20,6 +20,7 @@ async function _deleteAllTestData () { ALTER TABLE water.billing_transactions DISABLE TRIGGER ALL; ALTER TABLE water.billing_volumes DISABLE TRIGGER ALL; ALTER TABLE water.charge_elements DISABLE TRIGGER ALL; + ALTER TABLE water.charge_purposes DISABLE TRIGGER ALL; ALTER TABLE water.charge_versions DISABLE TRIGGER ALL; ALTER TABLE water.charge_version_workflows DISABLE TRIGGER ALL; ALTER TABLE water.licence_agreements DISABLE TRIGGER ALL; @@ -116,6 +117,18 @@ async function _deleteAllTestData () { FROM "water"."charge_version_workflows"; + DELETE + FROM + "water"."charge_purposes" AS "cp" + USING "water"."charge_elements" AS "ce", + "water"."charge_versions" AS "cv", + "water"."licences" AS "l" + WHERE + "l"."is_test" = TRUE + AND "cp"."charge_element_id" = "ce"."charge_element_id" + AND "ce"."charge_version_id" = "cv"."charge_version_id" + AND "cv"."licence_id" = "l"."licence_id"; + DELETE FROM "water"."charge_elements" AS "ce" @@ -134,6 +147,22 @@ async function _deleteAllTestData () { "l"."is_test" = TRUE AND "cv"."licence_id" = "l"."licence_id"; + DELETE + FROM + "water"."charge_purposes" + WHERE + "is_test" = TRUE; + DELETE + FROM + "water"."charge_elements" + WHERE + "is_test" = TRUE; + DELETE + FROM + "water"."charge_versions" + WHERE + "is_test" = TRUE; + DELETE FROM "water"."return_requirement_purposes" AS "rrp" @@ -259,6 +288,7 @@ async function _deleteAllTestData () { ALTER TABLE water.billing_transactions ENABLE TRIGGER ALL; ALTER TABLE water.billing_volumes ENABLE TRIGGER ALL; ALTER TABLE water.charge_elements ENABLE TRIGGER ALL; + ALTER TABLE water.charge_purposes ENABLE TRIGGER ALL; ALTER TABLE water.charge_versions ENABLE TRIGGER ALL; ALTER TABLE water.charge_version_workflows ENABLE TRIGGER ALL; ALTER TABLE water.licence_agreements ENABLE TRIGGER ALL;