From 2bc0e762bfe3c7370b52e1f01bc371c1b2c0846d Mon Sep 17 00:00:00 2001 From: Fredrik Ringqvist Date: Wed, 24 Apr 2019 13:23:28 +0200 Subject: [PATCH] P5-3704 delete state and delivery state from non USA orders --- migrations/000.104.sql | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 migrations/000.104.sql diff --git a/migrations/000.104.sql b/migrations/000.104.sql new file mode 100644 index 0000000..e75e0f0 --- /dev/null +++ b/migrations/000.104.sql @@ -0,0 +1,15 @@ +-- P5-3704 Remove state from non US orders + +-- Remove state (235) values when countryCode (151) is not US +DELETE FROM "order-orders_fields" +WHERE fieldid = 235 AND orderid IN ( + SELECT orders.orderid FROM "order-orders" orders + JOIN "order-orders_fields" countryCode ON countryCode.fieldid = 151 AND countryCode.orderid = orders.orderid + WHERE countryCode.value != 'US' +); + +-- Remove delivery-state (242) values when delivery-countryCode (213) is not US +DELETE FROM "order-orders_fields" +WHERE fieldid = 242 AND orderid IN ( + SELECT orderid FROM "order-orders_fields" WHERE fieldid = 213 AND value != 'US' +);