Skip to content

Instantly share code, notes, and snippets.

@psyray
Forked from julienbourdeau/clean-prestashop-db.sql
Created August 29, 2020 10:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save psyray/930e89561aa53e54af3de88062e44eb1 to your computer and use it in GitHub Desktop.
Save psyray/930e89561aa53e54af3de88062e44eb1 to your computer and use it in GitHub Desktop.
Clean PrestaShop database - Drop old and unless data
# Delete all logs
TRUNCATE ps_log;
# Delete old connection data (only used for stats)
# change 2016-02-01 00:00:00 according to you needs
DELETE c, cs
FROM ps_connections c
LEFT JOIN ps_connections_source cs ON (c.id_connections = cs.id_connections)
WHERE c.date_add < '2016-02-01 00:00:00';
OPTIMIZE TABLE ps_connections, ps_connections_source;
# Delete all guest without entry in ps_customer table
DELETE g
FROM ps_guest g
LEFT JOIN ps_customer c ON (g.id_customer = c.id_customer)
WHERE c.id_customer IS NULL;
OPTIMIZE TABLE ps_guest;
# Delete tables
# Scenes are deprecated in 1.6 (used only if upgrading with feature active)
DROP TABLE `ps_scene`;
DROP TABLE `ps_scene_category`;
DROP TABLE `ps_scene_lang`;
TRUNCATE `ps_scene_products`;
DROP TABLE `ps_scene_shop`;
UPDATE `ps_configuration` SET value='0', date_upd=NOW() WHERE `name` = 'PS_SCENE_FEATURE_ACTIVE';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment