migrations/Version20230530124801.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 Version20230530124801 extends AbstractMigration
  7. {
  8.     public function getDescription(): string
  9.     {
  10.         return 'Announcements-to-countries join table';
  11.     }
  12.     public function up(Schema $schema): void
  13.     {
  14.         $this->addSql("
  15.             CREATE TABLE `announcement_country`  (
  16.               `announcement_id` bigint UNSIGNED NOT NULL,
  17.               `country_id` int UNSIGNED NOT NULL,
  18.               PRIMARY KEY (`announcement_id`, `country_id`) USING BTREE,
  19.               INDEX `announcement_country_ibfk_2`(`country_id`) USING BTREE,
  20.               CONSTRAINT `announcement_country_ibfk_1` FOREIGN KEY (`announcement_id`) REFERENCES `announcement` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT,
  21.               CONSTRAINT `announcement_country_ibfk_2` FOREIGN KEY (`country_id`) REFERENCES `country` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT
  22.             ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
  23.         ");
  24.     }
  25.     public function down(Schema $schema): void
  26.     {
  27.         $this->addSql("DROP TABLE IF EXISTS `announcement_country`");
  28.     }
  29. }