migrations/Version20251027105032.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.  * Auto-generated Migration: Please modify to your needs!
  8.  */
  9. final class Version20251027105032 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return 'Create table std_ads_targeting_tags for tag-level targeting (many-to-many with rules)';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         $this->addSql(<<<'SQL'
  18.             CREATE TABLE `std_ads_targeting_tags` (
  19.             `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  20.             `rule_id` INT UNSIGNED NOT NULL,
  21.             `domain_value_id` INT NOT NULL,
  22.             PRIMARY KEY (`id`),
  23.             KEY `idx_targeting_tags_rule` (`rule_id`),
  24.             KEY `idx_targeting_tags_domain` (`domain_value_id`),
  25.             CONSTRAINT `fk_targeting_tags_rule`
  26.                 FOREIGN KEY (`rule_id`)
  27.                 REFERENCES `std_ads_targeting_rules` (`id`)
  28.                 ON DELETE CASCADE,
  29.             CONSTRAINT `fk_targeting_tags_domain`
  30.                 FOREIGN KEY (`domain_value_id`)
  31.                 REFERENCES `std_domains_values` (`id`)
  32.                 ON DELETE CASCADE
  33.             ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  34.         SQL);
  35.     }
  36.     public function down(Schema $schema): void
  37.     {
  38.         $this->addSql('DROP TABLE IF EXISTS `std_ads_targeting_tags`');
  39.     }
  40. }