app/DoctrineMigrations/Version20260207212323.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. /**
  7.  * サイトマップ統計情報スナップショットテーブル作成
  8.  */
  9. final class Version20260207212323 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return 'サイトマップ統計情報スナップショットテーブル(dtb_sitemap_statistics_snapshot)を作成';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         $this->addSql("
  18.             CREATE TABLE dtb_sitemap_statistics_snapshot (
  19.                 id INT UNSIGNED NOT NULL AUTO_INCREMENT,
  20.                 snapshot_date DATE NOT NULL,
  21.                 total INT NOT NULL DEFAULT 0,
  22.                 indexed INT NOT NULL DEFAULT 0,
  23.                 pending INT NOT NULL DEFAULT 0,
  24.                 hold INT NOT NULL DEFAULT 0,
  25.                 noindex INT NOT NULL DEFAULT 0,
  26.                 created_at DATETIME NOT NULL,
  27.                 PRIMARY KEY (id),
  28.                 UNIQUE KEY unique_snapshot_date (snapshot_date),
  29.                 INDEX idx_snapshot_date (snapshot_date)
  30.             ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
  31.         ");
  32.     }
  33.     public function down(Schema $schema): void
  34.     {
  35.         $this->addSql('DROP TABLE dtb_sitemap_statistics_snapshot');
  36.     }
  37. }