app/DoctrineMigrations/Version20260204112608.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 Version20260204112608 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return 'インデックスコマンド実行ログテーブル(dtb_index_command_log)を作成';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         $this->addSql("
  18.             CREATE TABLE dtb_index_command_log (
  19.                 id INT UNSIGNED NOT NULL AUTO_INCREMENT,
  20.                 command_name VARCHAR(64) NOT NULL,
  21.                 executed_at DATETIME NOT NULL,
  22.                 new_products_count INT NOT NULL DEFAULT 0,
  23.                 inspected_count INT NOT NULL DEFAULT 0,
  24.                 status_changed_count INT NOT NULL DEFAULT 0,
  25.                 error_log TEXT NULL,
  26.                 status VARCHAR(16) NOT NULL DEFAULT 'success',
  27.                 created_at DATETIME NOT NULL,
  28.                 PRIMARY KEY (id),
  29.                 INDEX idx_executed_at (executed_at),
  30.                 INDEX idx_command_name (command_name),
  31.                 INDEX idx_status (status)
  32.             ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
  33.         ");
  34.     }
  35.     public function down(Schema $schema): void
  36.     {
  37.         $this->addSql('DROP TABLE dtb_index_command_log');
  38.     }
  39. }