<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20251027105025 extends AbstractMigration
{
public function getDescription(): string
{
return 'Create table std_ads_targeting_pages for page-level targeting (many-to-many with rules)';
}
public function up(Schema $schema): void
{
$this->addSql(<<<'SQL'
CREATE TABLE `std_ads_targeting_pages` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`rule_id` INT UNSIGNED NOT NULL,
`page_id` INT UNSIGNED NOT NULL,
PRIMARY KEY (`id`),
KEY `idx_targeting_pages_rule` (`rule_id`),
KEY `idx_targeting_pages_page` (`page_id`),
CONSTRAINT `fk_targeting_pages_rule`
FOREIGN KEY (`rule_id`)
REFERENCES `std_ads_targeting_rules` (`id`)
ON DELETE CASCADE,
CONSTRAINT `fk_targeting_pages_page`
FOREIGN KEY (`page_id`)
REFERENCES `std_pages` (`id`)
ON DELETE CASCADE
)
ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
SQL);
}
public function down(Schema $schema): void
{
$this->addSql('DROP TABLE IF EXISTS `std_ads_targeting_pages`');
}
}