<?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 Version20220203225312 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_profile (id INT AUTO_INCREMENT NOT NULL, branch_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, number_employees INT DEFAULT NULL, premium TINYINT(1) NOT NULL, INDEX IDX_A105B0D8DCD6CC49 (branch_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE company_profile_territory (company_profile_id INT NOT NULL, territory_id INT NOT NULL, INDEX IDX_97641E57174FB2E (company_profile_id), INDEX IDX_97641E573F74AD4 (territory_id), PRIMARY KEY(company_profile_id, territory_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE territory (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL, population VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE territory_living_environment (territory_id INT NOT NULL, living_environment_id INT NOT NULL, INDEX IDX_1342249C73F74AD4 (territory_id), INDEX IDX_1342249C55A97988 (living_environment_id), PRIMARY KEY(territory_id, living_environment_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE territory_branch_activity (territory_id INT NOT NULL, branch_activity_id INT NOT NULL, INDEX IDX_3CC6AC5773F74AD4 (territory_id), INDEX IDX_3CC6AC57D0CC46C (branch_activity_id), PRIMARY KEY(territory_id, branch_activity_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE company_profile ADD CONSTRAINT FK_A105B0D8DCD6CC49 FOREIGN KEY (branch_id) REFERENCES branch_activity (id)');
$this->addSql('ALTER TABLE company_profile_territory ADD CONSTRAINT FK_97641E57174FB2E FOREIGN KEY (company_profile_id) REFERENCES company_profile (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE company_profile_territory ADD CONSTRAINT FK_97641E573F74AD4 FOREIGN KEY (territory_id) REFERENCES territory (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE territory_living_environment ADD CONSTRAINT FK_1342249C73F74AD4 FOREIGN KEY (territory_id) REFERENCES territory (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE territory_living_environment ADD CONSTRAINT FK_1342249C55A97988 FOREIGN KEY (living_environment_id) REFERENCES living_environment (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE territory_branch_activity ADD CONSTRAINT FK_3CC6AC5773F74AD4 FOREIGN KEY (territory_id) REFERENCES territory (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE territory_branch_activity ADD CONSTRAINT FK_3CC6AC57D0CC46C FOREIGN KEY (branch_activity_id) REFERENCES branch_activity (id) ON DELETE CASCADE');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE company_profile_territory DROP FOREIGN KEY FK_97641E57174FB2E');
$this->addSql('ALTER TABLE company_profile_territory DROP FOREIGN KEY FK_97641E573F74AD4');
$this->addSql('ALTER TABLE territory_living_environment DROP FOREIGN KEY FK_1342249C73F74AD4');
$this->addSql('ALTER TABLE territory_branch_activity DROP FOREIGN KEY FK_3CC6AC5773F74AD4');
$this->addSql('DROP TABLE company_profile');
$this->addSql('DROP TABLE company_profile_territory');
$this->addSql('DROP TABLE territory');
$this->addSql('DROP TABLE territory_living_environment');
$this->addSql('DROP TABLE territory_branch_activity');
}
}