<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20251027105018 extends AbstractMigration
{
public function getDescription(): string
{
return 'Create table std_ads_campaigns for ad campaign configuration and tracking';
}
public function up(Schema $schema): void
{
$this->addSql(<<<'SQL'
CREATE TABLE `std_ads_campaigns` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`client_id` INT UNSIGNED NOT NULL,
`name` VARCHAR(255) NOT NULL,
`start_date` DATE NULL,
`end_date` DATE NULL,
`max_clicks_per_day` INT DEFAULT 0,
`click_value` DECIMAL(10,2) DEFAULT 0.00,
`rotation_type` VARCHAR(20) DEFAULT 'random',
`is_active` TINYINT(1) DEFAULT 1,
`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_campaign_client` (`client_id`),
CONSTRAINT `fk_campaign_client`
FOREIGN KEY (`client_id`)
REFERENCES `std_ads_clients` (`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_campaigns`');
}
}