<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20231204150956 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$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');
$this->addSql('ALTER TABLE company_translation ADD CONSTRAINT FK_ADB8FDF7E559DFD1 FOREIGN KEY (locale_id) REFERENCES locale (id)');
$this->addSql('ALTER TABLE company_translation ADD CONSTRAINT FK_ADB8FDF7979B1AD6 FOREIGN KEY (company_id) REFERENCES company (id)');
$this->addSql('INSERT INTO company_translation (locale_id, company_id)
SELECT fl.locale_id, c.id AS company_id
FROM franchise f
JOIN franchise_locale fl ON f.id = fl.franchise_id
JOIN company c ON f.id = c.franchise_id');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DELETE FROM company_translation');
$this->addSql('ALTER TABLE company_translation DROP FOREIGN KEY FK_ADB8FDF7E559DFD1');
$this->addSql('ALTER TABLE company_translation DROP FOREIGN KEY FK_ADB8FDF7979B1AD6');
$this->addSql('DROP TABLE company_translation');
}
}