From 4521cdb44f5c300f1c074a65625b1bdb59f989ba Mon Sep 17 00:00:00 2001 From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com> Date: Mon, 7 Oct 2024 12:28:42 +0200 Subject: [PATCH 1/9] update_from_4.3_new_commerce.md: Drop old tables: MySQL query --- .../from_4.3/update_from_4.3_new_commerce.md | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md b/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md index 9fa615f70c..a2615f2874 100644 --- a/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md +++ b/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md @@ -318,6 +318,35 @@ Apply the following database update scripts: psql < vendor/ibexa/installer/upgrade/db/postgresql/commerce/ibexa-4.3.latest-to-4.4.0.sql ``` +If you used old Commerce packages before, and have migrated everything, you can remove the old tables. +The removable table are prefixed with `ses_` and `sve_`. + +=== "MySQL" + + To list the removable tables: + ``` sql + SHOW TABLES FROM `` WHERE `Tables_in_` LIKE 'ses_%' OR `Tables_in_` LIKE 'sve_%'; + ``` + + To build a query to drop all those tables and execute it as a statement: + ``` sql + SELECT CONCAT('DROP TABLE ', GROUP_CONCAT('`', `table_schema`, '`.`', `table_name`, '`' SEPARATOR ', ')) + INTO @drop_query + FROM `information_schema`.`tables` + WHERE `table_schema` = '' AND (`table_name` LIKE 'ses_%' OR `table_name` LIKE 'sve_%') + ; + + PREPARE drop_stmt FROM @drop_query; + EXECUTE drop_stmt; + DEALLOCATE PREPARE drop_stmt; + ``` + +=== "PostgreSQL" + + ```sql + TODO + ``` + #### Ibexa Open Source If you have no access to Ibexa DXP's `ibexa/installer` package, database upgrade is not necessary. From 1f78dc017d49d8bbb7839f7eed4c76788a82a7da Mon Sep 17 00:00:00 2001 From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com> Date: Mon, 7 Oct 2024 15:13:41 +0200 Subject: [PATCH 2/9] update_from_4.3_new_commerce.md: Drop old tables: PostgreSQL query --- .../from_4.3/update_from_4.3_new_commerce.md | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md b/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md index a2615f2874..643a880572 100644 --- a/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md +++ b/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md @@ -344,7 +344,29 @@ The removable table are prefixed with `ses_` and `sve_`. === "PostgreSQL" ```sql - TODO + SHOW TABLES FROM WHERE Tables_in_ LIKE 'ses_%' OR Tables_in_ LIKE 'sve_%'; + ``` + + ```sql + FOR table_row IN + SELECT + table_schema, + table_name + FROM + information_schema.tables + WHERE + table_type = 'BASE TABLE' + AND + table_schema = '' + AND + ( + table_name LIKE ('ses_%') + OR + table_name LIKE ('sve_%') + ) + LOOP + EXECUTE 'DROP TABLE ' || table_row.table_schema || '.' || table_row.table_name; + END LOOP; ``` #### Ibexa Open Source From 3911ca30d769e9670129c494c4704f73181f90e1 Mon Sep 17 00:00:00 2001 From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com> Date: Tue, 8 Oct 2024 09:47:39 +0200 Subject: [PATCH 3/9] update_from_4.3_new_commerce.md: opt. MySQL query --- .../from_4.3/update_from_4.3_new_commerce.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md b/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md index 643a880572..220494eb7a 100644 --- a/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md +++ b/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md @@ -335,10 +335,7 @@ The removable table are prefixed with `ses_` and `sve_`. FROM `information_schema`.`tables` WHERE `table_schema` = '' AND (`table_name` LIKE 'ses_%' OR `table_name` LIKE 'sve_%') ; - - PREPARE drop_stmt FROM @drop_query; - EXECUTE drop_stmt; - DEALLOCATE PREPARE drop_stmt; + EXECUTE IMMEDIATE @drop_query; ``` === "PostgreSQL" From acdb3862e8f5f7839f3f9b1a8443a32ed2c38de6 Mon Sep 17 00:00:00 2001 From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com> Date: Tue, 8 Oct 2024 09:47:48 +0200 Subject: [PATCH 4/9] Revert "update_from_4.3_new_commerce.md: opt. MySQL query" This reverts commit 3911ca30d769e9670129c494c4704f73181f90e1. --- .../from_4.3/update_from_4.3_new_commerce.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md b/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md index 220494eb7a..643a880572 100644 --- a/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md +++ b/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md @@ -335,7 +335,10 @@ The removable table are prefixed with `ses_` and `sve_`. FROM `information_schema`.`tables` WHERE `table_schema` = '' AND (`table_name` LIKE 'ses_%' OR `table_name` LIKE 'sve_%') ; - EXECUTE IMMEDIATE @drop_query; + + PREPARE drop_stmt FROM @drop_query; + EXECUTE drop_stmt; + DEALLOCATE PREPARE drop_stmt; ``` === "PostgreSQL" From 88f1685fcb92a122371a705354b06d43135699d9 Mon Sep 17 00:00:00 2001 From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com> Date: Tue, 8 Oct 2024 09:49:13 +0200 Subject: [PATCH 5/9] update_from_4.3_new_commerce.md: fix [Ibexa.EOLWhitespace] --- .../from_4.3/update_from_4.3_new_commerce.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md b/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md index 643a880572..87f1f2a00f 100644 --- a/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md +++ b/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md @@ -335,7 +335,7 @@ The removable table are prefixed with `ses_` and `sve_`. FROM `information_schema`.`tables` WHERE `table_schema` = '' AND (`table_name` LIKE 'ses_%' OR `table_name` LIKE 'sve_%') ; - + PREPARE drop_stmt FROM @drop_query; EXECUTE drop_stmt; DEALLOCATE PREPARE drop_stmt; @@ -348,7 +348,7 @@ The removable table are prefixed with `ses_` and `sve_`. ``` ```sql - FOR table_row IN + FOR table_row IN SELECT table_schema, table_name @@ -363,7 +363,7 @@ The removable table are prefixed with `ses_` and `sve_`. table_name LIKE ('ses_%') OR table_name LIKE ('sve_%') - ) + ) LOOP EXECUTE 'DROP TABLE ' || table_row.table_schema || '.' || table_row.table_name; END LOOP; From 1f5b1fe454e52fc24fa4d6bcca447d352d0dadf7 Mon Sep 17 00:00:00 2001 From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com> Date: Tue, 8 Oct 2024 12:11:43 +0200 Subject: [PATCH 6/9] update_from_4.3_new_commerce.md: Drop old tables: PostgreSQL query --- .../from_4.3/update_from_4.3_new_commerce.md | 39 +++++++++---------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md b/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md index 87f1f2a00f..d98707ae58 100644 --- a/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md +++ b/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md @@ -343,30 +343,29 @@ The removable table are prefixed with `ses_` and `sve_`. === "PostgreSQL" + To list the removable tables: ```sql - SHOW TABLES FROM WHERE Tables_in_ LIKE 'ses_%' OR Tables_in_ LIKE 'sve_%'; + SELECT tableowner, tablename + FROM pg_catalog.pg_tables + WHERE schemaname='public' AND tableowner='' AND (tablename LIKE 'ses_%' OR tablename LIKE 'sve_%'); ``` + To loop through the tables to drop them (be sure to use the right database with `\connect ;`.): ```sql - FOR table_row IN - SELECT - table_schema, - table_name - FROM - information_schema.tables - WHERE - table_type = 'BASE TABLE' - AND - table_schema = '' - AND - ( - table_name LIKE ('ses_%') - OR - table_name LIKE ('sve_%') - ) - LOOP - EXECUTE 'DROP TABLE ' || table_row.table_schema || '.' || table_row.table_name; - END LOOP; + DO $drop$ + DECLARE table_row RECORD; + BEGIN + FOR table_row IN + SELECT table_catalog, table_name + FROM information_schema.tables + WHERE table_schema = 'public' AND table_type = 'BASE TABLE' + AND table_catalog = 'db' AND (table_name LIKE ('ses_%') OR table_name LIKE ('sve_%')) + LOOP + EXECUTE 'DROP TABLE ' || table_row.table_name; + END LOOP + ; + END + $drop$; ``` #### Ibexa Open Source From 96de2d9af6f1eb9e7617a7cfccb2217c78f17c0d Mon Sep 17 00:00:00 2001 From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com> Date: Tue, 8 Oct 2024 16:19:30 +0200 Subject: [PATCH 7/9] Update docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md --- .../from_4.3/update_from_4.3_new_commerce.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md b/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md index d98707ae58..596e2bc6b6 100644 --- a/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md +++ b/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md @@ -319,7 +319,7 @@ Apply the following database update scripts: ``` If you used old Commerce packages before, and have migrated everything, you can remove the old tables. -The removable table are prefixed with `ses_` and `sve_`. +The removable tables are prefixed with `ses_` and `sve_`. === "MySQL" From 7206ea5a105419c182ee3285374fcfbcb924b08b Mon Sep 17 00:00:00 2001 From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com> Date: Tue, 8 Oct 2024 16:26:36 +0200 Subject: [PATCH 8/9] update_from_4.3_new_commerce.md: Hard code ses_% sve_% table list --- .../from_4.3/update_from_4.3_new_commerce.md | 98 ++++++++++++------- 1 file changed, 65 insertions(+), 33 deletions(-) diff --git a/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md b/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md index 596e2bc6b6..ff1d9f74c8 100644 --- a/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md +++ b/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md @@ -323,49 +323,81 @@ The removable tables are prefixed with `ses_` and `sve_`. === "MySQL" - To list the removable tables: + To be on the right database, adapt the following command: ``` sql - SHOW TABLES FROM `` WHERE `Tables_in_` LIKE 'ses_%' OR `Tables_in_` LIKE 'sve_%'; + USE ; ``` - To build a query to drop all those tables and execute it as a statement: + Then, to remove all the old tables, run the following queries: ``` sql - SELECT CONCAT('DROP TABLE ', GROUP_CONCAT('`', `table_schema`, '`.`', `table_name`, '`' SEPARATOR ', ')) - INTO @drop_query - FROM `information_schema`.`tables` - WHERE `table_schema` = '' AND (`table_name` LIKE 'ses_%' OR `table_name` LIKE 'sve_%') - ; - - PREPARE drop_stmt FROM @drop_query; - EXECUTE drop_stmt; - DEALLOCATE PREPARE drop_stmt; + DROP TABLE IF EXISTS ses_basket; + DROP TABLE IF EXISTS ses_basket_line; + DROP TABLE IF EXISTS ses_content_modification_queue; + DROP TABLE IF EXISTS ses_customer_prices; + DROP TABLE IF EXISTS ses_customer_sku; + DROP TABLE IF EXISTS ses_download; + DROP TABLE IF EXISTS ses_externaldata; + DROP TABLE IF EXISTS ses_gdpr_log; + DROP TABLE IF EXISTS ses_invoice; + DROP TABLE IF EXISTS ses_log_erp; + DROP TABLE IF EXISTS ses_log_mail; + DROP TABLE IF EXISTS ses_log_search; + DROP TABLE IF EXISTS ses_payment_basket_map; + DROP TABLE IF EXISTS ses_price; + DROP TABLE IF EXISTS ses_shipping_cost; + DROP TABLE IF EXISTS ses_stat_sessions; + DROP TABLE IF EXISTS ses_stock; + DROP TABLE IF EXISTS ses_token; + DROP TABLE IF EXISTS sve_class; + DROP TABLE IF EXISTS sve_class_attributes; + DROP TABLE IF EXISTS sve_object; + DROP TABLE IF EXISTS sve_object_attributes; + DROP TABLE IF EXISTS sve_object_attributes_tmp; + DROP TABLE IF EXISTS sve_object_catalog; + DROP TABLE IF EXISTS sve_object_catalog_tmp; + DROP TABLE IF EXISTS sve_object_tmp; + DROP TABLE IF EXISTS sve_object_urls; + DROP TABLE IF EXISTS sve_object_urls_tmp; ``` === "PostgreSQL" - To list the removable tables: - ```sql - SELECT tableowner, tablename - FROM pg_catalog.pg_tables - WHERE schemaname='public' AND tableowner='' AND (tablename LIKE 'ses_%' OR tablename LIKE 'sve_%'); + To be on the right database, adapt the following command: + ``` sql + \connect ; ``` - To loop through the tables to drop them (be sure to use the right database with `\connect ;`.): - ```sql - DO $drop$ - DECLARE table_row RECORD; - BEGIN - FOR table_row IN - SELECT table_catalog, table_name - FROM information_schema.tables - WHERE table_schema = 'public' AND table_type = 'BASE TABLE' - AND table_catalog = 'db' AND (table_name LIKE ('ses_%') OR table_name LIKE ('sve_%')) - LOOP - EXECUTE 'DROP TABLE ' || table_row.table_name; - END LOOP - ; - END - $drop$; + + Then, to remove all the old tables, run the following queries: + ``` sql + DROP TABLE IF EXISTS ses_basket; + DROP TABLE IF EXISTS ses_basket_line; + DROP TABLE IF EXISTS ses_content_modification_queue; + DROP TABLE IF EXISTS ses_customer_prices; + DROP TABLE IF EXISTS ses_customer_sku; + DROP TABLE IF EXISTS ses_download; + DROP TABLE IF EXISTS ses_externaldata; + DROP TABLE IF EXISTS ses_gdpr_log; + DROP TABLE IF EXISTS ses_invoice; + DROP TABLE IF EXISTS ses_log_erp; + DROP TABLE IF EXISTS ses_log_mail; + DROP TABLE IF EXISTS ses_log_search; + DROP TABLE IF EXISTS ses_payment_basket_map; + DROP TABLE IF EXISTS ses_price; + DROP TABLE IF EXISTS ses_shipping_cost; + DROP TABLE IF EXISTS ses_stat_sessions; + DROP TABLE IF EXISTS ses_stock; + DROP TABLE IF EXISTS ses_token; + DROP TABLE IF EXISTS sve_class; + DROP TABLE IF EXISTS sve_class_attributes; + DROP TABLE IF EXISTS sve_object; + DROP TABLE IF EXISTS sve_object_attributes; + DROP TABLE IF EXISTS sve_object_attributes_tmp; + DROP TABLE IF EXISTS sve_object_catalog; + DROP TABLE IF EXISTS sve_object_catalog_tmp; + DROP TABLE IF EXISTS sve_object_tmp; + DROP TABLE IF EXISTS sve_object_urls; + DROP TABLE IF EXISTS sve_object_urls_tmp; ``` #### Ibexa Open Source From 048749c15b67f8cdb38df18813dc3216d2de692b Mon Sep 17 00:00:00 2001 From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com> Date: Mon, 14 Oct 2024 14:11:12 +0200 Subject: [PATCH 9/9] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Tomasz DÄ…browski <64841871+dabrt@users.noreply.github.com> --- .../from_4.3/update_from_4.3_new_commerce.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md b/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md index ff1d9f74c8..28019b80b4 100644 --- a/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md +++ b/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md @@ -319,11 +319,11 @@ Apply the following database update scripts: ``` If you used old Commerce packages before, and have migrated everything, you can remove the old tables. -The removable tables are prefixed with `ses_` and `sve_`. +The tables that can be removed are prefixed with `ses_` and `sve_`. === "MySQL" - To be on the right database, adapt the following command: + To switch to the right database, issue the following command: ``` sql USE ; ``` @@ -362,7 +362,7 @@ The removable tables are prefixed with `ses_` and `sve_`. === "PostgreSQL" - To be on the right database, adapt the following command: + To switch to the right database, issue the following command: ``` sql \connect ; ```