migrations/Version20251027105018.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. final class Version20251027105018 extends AbstractMigration
  7. {
  8.     public function getDescription(): string
  9.     {
  10.         return 'Create table std_ads_campaigns for ad campaign configuration and tracking';
  11.     }
  12.     public function up(Schema $schema): void
  13.     {
  14.         $this->addSql(<<<'SQL'
  15.             CREATE TABLE `std_ads_campaigns` (
  16.               `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  17.               `client_id` INT UNSIGNED NOT NULL,
  18.               `name` VARCHAR(255) NOT NULL,
  19.               `start_date` DATE NULL,
  20.               `end_date` DATE NULL,
  21.               `max_clicks_per_day` INT DEFAULT 0,
  22.               `click_value` DECIMAL(10,2) DEFAULT 0.00,
  23.               `rotation_type` VARCHAR(20) DEFAULT 'random',
  24.               `is_active` TINYINT(1) DEFAULT 1,
  25.               `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  26.               `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  27.               PRIMARY KEY (`id`),
  28.               KEY `idx_campaign_client` (`client_id`),
  29.               CONSTRAINT `fk_campaign_client`
  30.                 FOREIGN KEY (`client_id`)
  31.                 REFERENCES `std_ads_clients` (`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_campaigns`');
  39.     }
  40. }