app/DoctrineMigrations/Version20260123144511.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 Version20260123144511 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '商品検索インデックス状態管理テーブル(dtb_product_search_index)を作成';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         $this->addSql("
  18.             CREATE TABLE dtb_product_search_index (
  19.                 product_id INT UNSIGNED NOT NULL,
  20.                 url VARCHAR(255) NOT NULL,
  21.                 status ENUM('indexed','pending','hold','noindex') NOT NULL DEFAULT 'pending',
  22.                 status_changed_at DATETIME NOT NULL,
  23.                 last_checked_at DATETIME NULL,
  24.                 source VARCHAR(32) NULL,
  25.                 created_at DATETIME NOT NULL,
  26.                 updated_at DATETIME NOT NULL,
  27.                 PRIMARY KEY (product_id),
  28.                 INDEX idx_status (status),
  29.                 INDEX idx_status_changed_at (status_changed_at)
  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_product_search_index');
  36.     }
  37. }