d3nysm/stats-tables-cleaner-bundle

Cleans old entries from database stats tables

1.0.3 2023-05-02 07:48 UTC

This package is auto-updated.

Last update: 2024-05-01 00:10:38 UTC


README

This bundle helps with cleaning tables with statistics, logs, etc. The necessary thing is an entity must have date or datetime column.

Installation

$ composer require d3nysm/stats-tables-cleaner-bundle

Quick Start

  1. Add the notation to your entity:

    use App\Repository\StatsEntryRepository;
    use Doctrine\ORM\Mapping as ORM;
    use D3nysm\Bundle\StatsTablesCleaner\Annotation\CleanOldData;
    
    /**
     * @ORM\Entity(repositoryClass=StatsEntryRepository::class)
     * @ORM\Table(indexes={
     *     @ORM\Index(name="stat_date", columns={"date"})})
     * @CleanOldData(interval="-3 month")
    */
    class StatsEntry

    Full settings of the annotation:

    /**
     * @DeleteOldData(dateProp="createdAt", interval="-1 month", batchSize=500, eventName="app.my_best_event")
    */
  2. Run the command and add to you scheduler system:

    $ php bin/console stats-tables-cleaner:clean