<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20230530124801 extends AbstractMigration
{
public function getDescription(): string
{
return 'Announcements-to-countries join table';
}
public function up(Schema $schema): void
{
$this->addSql("
CREATE TABLE `announcement_country` (
`announcement_id` bigint UNSIGNED NOT NULL,
`country_id` int UNSIGNED NOT NULL,
PRIMARY KEY (`announcement_id`, `country_id`) USING BTREE,
INDEX `announcement_country_ibfk_2`(`country_id`) USING BTREE,
CONSTRAINT `announcement_country_ibfk_1` FOREIGN KEY (`announcement_id`) REFERENCES `announcement` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT,
CONSTRAINT `announcement_country_ibfk_2` FOREIGN KEY (`country_id`) REFERENCES `country` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
");
}
public function down(Schema $schema): void
{
$this->addSql("DROP TABLE IF EXISTS `announcement_country`");
}
}