Skip to content
50 changes: 50 additions & 0 deletions docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,56 @@ Apply the following database update scripts:
psql <database_name> < 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 tables are prefixed with `ses_` and `sve_`.

=== "MySQL"

To list the removable tables:
``` sql
SHOW TABLES FROM `<database_name>` WHERE `Tables_in_<database_name>` LIKE 'ses_%' OR `Tables_in_<database_name>` 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` = '<database_name>' AND (`table_name` LIKE 'ses_%' OR `table_name` LIKE 'sve_%')
;

PREPARE drop_stmt FROM @drop_query;
EXECUTE drop_stmt;
DEALLOCATE PREPARE drop_stmt;
```

=== "PostgreSQL"

To list the removable tables:
```sql
SELECT tableowner, tablename
FROM pg_catalog.pg_tables
WHERE schemaname='public' AND tableowner='<database_name>' 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 <database_name>;`.):
```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$;
```

#### Ibexa Open Source

If you have no access to Ibexa DXP's `ibexa/installer` package, database upgrade is not necessary.
Expand Down
Loading