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-runReport 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.
| Data | Configuration variable | Default |
|---|---|---|
| Carts without an order | purification_cart_no_order_days | 60 days |
| Anonymous carts | purification_cart_anonymous_days | 30 days |
| Admin logs | purification_admin_logs_days | 180 days |
| Form firewall records | purification_form_firewall_days | 1 day |
| Identity of accounts that never ordered | purification_customer_no_order_days | 0, off |
| Identity of accounts whose last order is old | purification_customer_after_last_order_days | 0, 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().
The core listens to the same event to purge the back-office exports and imports, through
Thelia\Domain\DataTransfer\Service\DataTransferJobPurger: the done jobs older than 7 days,
any other (failed, queued, running) after 31 days, a day longer than the failed jobs they can be
replayed from, the uploaded file of each deleted import when it lies inside
var/data-transfer/import, and the files of that directory older than 31 days. The same listener removes the export files of the cache older
than a day; with --dry-run, it counts them and deletes none. These periods are fixed.
The failed jobs set aside in failed for more than 30 days are deleted on the same run
(Thelia\Messenger\EventListener\FailedJobsMaintenancePurgeListener), as
thelia:messenger:purge-failed does with its default. See Background jobs.
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
Run --dry-run after every change of period, and read the counts before letting the task
run unattended. See Personal data.