d3nysm/stats-tables-cleaner-bundle
This bundle helps with cleaning tables with statistics, logs, etc. The necessary thing is an entity must have date or datetime column.
$ composer require d3nysm/stats-tables-cleaner-bundle
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")
*/
Run the command and add to you scheduler system:
$ php bin/console stats-tables-cleaner:clean
How can I help you explore Laravel packages today?