From 0e0212254e4adeb75589adf6ebabecaf91ac9d9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9stor=20Soriano?= Date: Thu, 4 Aug 2022 13:22:08 +0200 Subject: [PATCH] [COT] Add unique key constraints for the addresses and operational data tables (#34144) * Add unique constraints to the COT addresses and operational tables * Add changelog file --- .../changelog/add-unique_key_constraints_for_cot_tables | 4 ++++ .../src/Internal/DataStores/Orders/OrdersTableDataStore.php | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 plugins/woocommerce/changelog/add-unique_key_constraints_for_cot_tables diff --git a/plugins/woocommerce/changelog/add-unique_key_constraints_for_cot_tables b/plugins/woocommerce/changelog/add-unique_key_constraints_for_cot_tables new file mode 100644 index 00000000000..1a6f29dda46 --- /dev/null +++ b/plugins/woocommerce/changelog/add-unique_key_constraints_for_cot_tables @@ -0,0 +1,4 @@ +Significance: minor +Type: dev + +Add unique constraints to the COT addresses and operational tables diff --git a/plugins/woocommerce/src/Internal/DataStores/Orders/OrdersTableDataStore.php b/plugins/woocommerce/src/Internal/DataStores/Orders/OrdersTableDataStore.php index 517ad7a750e..c962dea7582 100644 --- a/plugins/woocommerce/src/Internal/DataStores/Orders/OrdersTableDataStore.php +++ b/plugins/woocommerce/src/Internal/DataStores/Orders/OrdersTableDataStore.php @@ -1407,7 +1407,7 @@ CREATE TABLE $addresses_table_name ( email varchar(320) null, phone varchar(100) null, KEY order_id (order_id), - KEY address_type_order_id (address_type, order_id) + UNIQUE KEY address_type_order_id (address_type, order_id) ) $collate; CREATE TABLE $operational_data_table_name ( id bigint(20) unsigned auto_increment primary key, @@ -1428,8 +1428,8 @@ CREATE TABLE $operational_data_table_name ( discount_tax_amount decimal(26, 8) NULL, discount_total_amount decimal(26, 8) NULL, recorded_sales tinyint(1) NULL, - KEY order_id (order_id), - KEY order_key (order_key) + UNIQUE KEY order_id (order_id), + UNIQUE KEY order_key (order_key) ) $collate; CREATE TABLE $meta_table ( id bigint(20) unsigned auto_increment primary key,