d3nysm/stats-tables-cleaner-bundle

从数据库的统计表中清理旧条目

安装: 1

依赖: 0

建议者: 0

安全: 0

星级: 0

关注者: 1

分支: 0

开放问题: 0

类型:symfony-bundle

1.0.3 2023-05-02 07:48 UTC

This package is auto-updated.

Last update: 2024-10-01 00:25:52 UTC


README

此包有助于清理包含统计数据、日志等的表格。必要的是实体必须具有日期或日期时间列。

安装

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

快速开始

  1. 将注解添加到您的实体中

    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

    注解的完整设置

    /**
     * @DeleteOldData(dateProp="createdAt", interval="-1 month", batchSize=500, eventName="app.my_best_event")
    */
  2. 运行命令并将其添加到您的调度系统中

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