Skip to main content
Version: Next

maintenance:purge

Description

Purge old data from the database: carts without orders, anonymous carts, admin logs, form firewall records, and the identity of accounts nobody uses anymore.

Usage

maintenance:purge [options]

Options

  • --dry-run Report what the purge would remove, without touching anything.

Every period is a configuration variable, so a shop sets its own. Read and write them with thelia:config.

DataConfiguration variableDefault
Carts without an orderpurification_cart_no_order_days60 days
Anonymous cartspurification_cart_anonymous_days30 days
Admin logspurification_admin_logs_days180 days
Form firewall recordspurification_form_firewall_days1 day
Identity of accounts that never orderedpurification_customer_no_order_days0, off
Identity of accounts whose last order is oldpurification_customer_after_last_order_days0, off

Customer retention is off by default, on purpose: erasing an identity cannot be undone, and the shop is the only one that knows how long it is allowed to keep the data. When a period is set, the accounts are anonymized through CUSTOMER_ANONYMIZE, so modules erase their share on a scheduled run exactly as on a manual one, and an account already anonymized is skipped.

The form firewall threshold never goes below the longest waiting period configured, so a purge cannot hand a blocked IP address a fresh set of attempts.

At the end of its run the command dispatches TheliaEvents::MAINTENANCE_PURGE: a module listens to it, purges its own tables, and appends a line to the report with $event->addResult().

Examples

See what would be removed:

php Thelia maintenance:purge --dry-run

Run the purge, typically from a nightly task:

php Thelia maintenance:purge

Set a retention period of two years for accounts that never ordered:

php Thelia thelia:config set purification_customer_no_order_days 730
tip

Run --dry-run after every change of period, and read the counts before letting the task run unattended. See Personal data.