<?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 Version20220905124227 extends AbstractMigration
{
public function getDescription(): string
{
return 'Create table agency';
}
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE agency (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, departments LONGTEXT DEFAULT NULL, address1 VARCHAR(255) DEFAULT NULL, complement VARCHAR(255) DEFAULT NULL, postcode VARCHAR(10) DEFAULT NULL, city VARCHAR(255) DEFAULT NULL, iso_code VARCHAR(255) DEFAULT NULL, country VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE carrier_agency_carrier (carrier_agency_id INT NOT NULL, carrier_id INT NOT NULL, INDEX IDX_DCD307002747CF29 (carrier_agency_id), INDEX IDX_DCD3070021DFC797 (carrier_id), PRIMARY KEY(carrier_agency_id, carrier_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE carrier_agency_carrier ADD CONSTRAINT FK_DCD307002747CF29 FOREIGN KEY (carrier_agency_id) REFERENCES carrier_agency (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE carrier_agency_carrier ADD CONSTRAINT FK_DCD3070021DFC797 FOREIGN KEY (carrier_id) REFERENCES carrier (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE carrier_agency DROP FOREIGN KEY FK_5DB1A71021DFC797');
$this->addSql('DROP INDEX IDX_5DB1A71021DFC797 ON carrier_agency');
$this->addSql('ALTER TABLE carrier_agency DROP carrier_id');
}
public function down(Schema $schema): void
{
$this->addSql('DROP TABLE agency');
$this->addSql('DROP TABLE carrier_agency_carrier');
$this->addSql('ALTER TABLE carrier_agency ADD carrier_id INT NOT NULL');
$this->addSql('ALTER TABLE carrier_agency ADD CONSTRAINT FK_5DB1A71021DFC797 FOREIGN KEY (carrier_id) REFERENCES carrier (id) ON UPDATE NO ACTION ON DELETE NO ACTION');
$this->addSql('CREATE INDEX IDX_5DB1A71021DFC797 ON carrier_agency (carrier_id)');
}
}