<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20251027105020 extends AbstractMigration
{
public function getDescription(): string
{
return 'Create table std_advertisements (aligned UNSIGNED types)';
}
public function up(Schema $schema): void
{
$this->addSql(<<<'SQL'
CREATE TABLE `std_advertisements` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`campaign_id` INT UNSIGNED NULL,
`zone_id` INT UNSIGNED NULL,
`title` VARCHAR(255) NULL,
`description_tooltip` VARCHAR(255) NULL,
`media_path` VARCHAR(255) NULL,
`href` VARCHAR(512) NULL,
`open_in_new_tab` TINYINT(1) DEFAULT 1,
`nofollow` TINYINT(1) DEFAULT 1,
`weight` INT DEFAULT 1,
`clicks` INT DEFAULT 0,
`status` VARCHAR(20) DEFAULT 'open',
`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_advertisement_campaign` (`campaign_id`),
KEY `idx_advertisement_zone` (`zone_id`),
CONSTRAINT `fk_advertisement_campaign`
FOREIGN KEY (`campaign_id`)
REFERENCES `std_ads_campaigns` (`id`)
ON DELETE CASCADE,
CONSTRAINT `fk_advertisement_zone`
FOREIGN KEY (`zone_id`)
REFERENCES `std_ads_zones` (`id`)
ON DELETE SET NULL
)
ENGINE=InnoDB
DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_unicode_ci;
SQL);
}
public function down(Schema $schema): void
{
$this->addSql('DROP TABLE IF EXISTS `std_advertisements`');
}
}