migrations/Version20231204150956.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. /**
  7.  * Auto-generated Migration: Please modify to your needs!
  8.  */
  9. final class Version20231204150956 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         $this->addSql('CREATE TABLE company_translation (id INT AUTO_INCREMENT NOT NULL, locale_id INT NOT NULL, company_id INT NOT NULL, address LONGTEXT DEFAULT NULL, INDEX IDX_ADB8FDF7E559DFD1 (locale_id), INDEX IDX_ADB8FDF7979B1AD6 (company_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  19.         $this->addSql('ALTER TABLE company_translation ADD CONSTRAINT FK_ADB8FDF7E559DFD1 FOREIGN KEY (locale_id) REFERENCES locale (id)');
  20.         $this->addSql('ALTER TABLE company_translation ADD CONSTRAINT FK_ADB8FDF7979B1AD6 FOREIGN KEY (company_id) REFERENCES company (id)');
  21.         $this->addSql('INSERT INTO company_translation (locale_id, company_id)
  22.                         SELECT fl.locale_id, c.id AS company_id
  23.                         FROM franchise f
  24.                         JOIN franchise_locale fl ON f.id = fl.franchise_id
  25.                         JOIN company c ON f.id = c.franchise_id');
  26.     }
  27.     public function down(Schema $schema): void
  28.     {
  29.         // this down() migration is auto-generated, please modify it to your needs
  30.         $this->addSql('DELETE FROM company_translation');
  31.         $this->addSql('ALTER TABLE company_translation DROP FOREIGN KEY FK_ADB8FDF7E559DFD1');
  32.         $this->addSql('ALTER TABLE company_translation DROP FOREIGN KEY FK_ADB8FDF7979B1AD6');
  33.         $this->addSql('DROP TABLE company_translation');
  34.     }
  35. }