<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20251027105023 extends AbstractMigration
{
public function getDescription(): string
{
return 'Create table std_ads_targeting_rules to define targeting context for ad campaigns';
}
public function up(Schema $schema): void
{
$this->addSql(<<<'SQL'
CREATE TABLE `std_ads_targeting_rules` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`campaign_id` INT UNSIGNED NOT NULL,
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `idx_targeting_campaign` (`campaign_id`),
CONSTRAINT `fk_targeting_campaign`
FOREIGN KEY (`campaign_id`)
REFERENCES `std_ads_campaigns` (`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_rules`');
}
}