src/Migrations/Version20201026145106.php line 1
<?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 Version20201026145106 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('delete from university_category_relation');
$this->addSql('ALTER TABLE university_category_relation DROP FOREIGN KEY FK_EFBAC27D21D6F15');
$this->addSql('CREATE TABLE universities (id INT AUTO_INCREMENT NOT NULL, organisation_id INT DEFAULT NULL, have_dorm TINYINT(1) DEFAULT \'0\' NOT NULL, have_military_department TINYINT(1) DEFAULT \'0\' NOT NULL, UNIQUE INDEX UNIQ_E36065DE9E6B1585 (organisation_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE university_category (id INT AUTO_INCREMENT NOT NULL, created_by_id INT DEFAULT NULL, updated_by_id INT DEFAULT NULL, caption VARCHAR(255) NOT NULL, weight INT DEFAULT 10 NOT NULL, deleted TINYINT(1) DEFAULT \'0\' NOT NULL, created_at DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, updated_at DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, active TINYINT(1) DEFAULT \'1\' NOT NULL, INDEX IDX_BE513B6BB03A8386 (created_by_id), INDEX IDX_BE513B6B896DBBDE (updated_by_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE universities ADD CONSTRAINT FK_E36065DE9E6B1585 FOREIGN KEY (organisation_id) REFERENCES organisation (id)');
$this->addSql('ALTER TABLE university_category ADD CONSTRAINT FK_BE513B6BB03A8386 FOREIGN KEY (created_by_id) REFERENCES users (id)');
$this->addSql('ALTER TABLE university_category ADD CONSTRAINT FK_BE513B6B896DBBDE FOREIGN KEY (updated_by_id) REFERENCES users (id)');
$this->addSql('DROP TABLE university_categories');
$this->addSql('ALTER TABLE organisation ADD address LONGTEXT DEFAULT NULL, DROP have_dorm, DROP have_military_department');
$this->addSql('ALTER TABLE university_category_relation DROP FOREIGN KEY FK_EFBAC27D9E6B1585');
$this->addSql('DROP INDEX IDX_EFBAC27D9E6B1585 ON university_category_relation');
$this->addSql('DROP INDEX IDX_EFBAC27D21D6F15 ON university_category_relation');
$this->addSql('ALTER TABLE university_category_relation DROP PRIMARY KEY');
$this->addSql('ALTER TABLE university_category_relation ADD university_id INT NOT NULL, ADD category_id INT NOT NULL, DROP organisation_id, DROP university_category_id');
$this->addSql('ALTER TABLE university_category_relation ADD CONSTRAINT FK_EFBAC27D309D1878 FOREIGN KEY (university_id) REFERENCES universities (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE university_category_relation ADD CONSTRAINT FK_EFBAC27D12469DE2 FOREIGN KEY (category_id) REFERENCES university_category (id) ON DELETE CASCADE');
$this->addSql('CREATE INDEX IDX_EFBAC27D309D1878 ON university_category_relation (university_id)');
$this->addSql('CREATE INDEX IDX_EFBAC27D12469DE2 ON university_category_relation (category_id)');
$this->addSql('ALTER TABLE university_category_relation ADD PRIMARY KEY (university_id, category_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE university_category_relation DROP FOREIGN KEY FK_EFBAC27D309D1878');
$this->addSql('ALTER TABLE university_category_relation DROP FOREIGN KEY FK_EFBAC27D12469DE2');
$this->addSql('CREATE TABLE university_categories (id INT AUTO_INCREMENT NOT NULL, created_by_id INT DEFAULT NULL, updated_by_id INT DEFAULT NULL, caption VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, deleted TINYINT(1) DEFAULT \'0\' NOT NULL, created_at DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, updated_at DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, active TINYINT(1) DEFAULT \'1\' NOT NULL, weight INT DEFAULT 10 NOT NULL, INDEX IDX_BB7BEBF2896DBBDE (updated_by_id), INDEX IDX_BB7BEBF2B03A8386 (created_by_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
$this->addSql('ALTER TABLE university_categories ADD CONSTRAINT FK_BB7BEBF2896DBBDE FOREIGN KEY (updated_by_id) REFERENCES users (id)');
$this->addSql('ALTER TABLE university_categories ADD CONSTRAINT FK_BB7BEBF2B03A8386 FOREIGN KEY (created_by_id) REFERENCES users (id)');
$this->addSql('DROP TABLE universities');
$this->addSql('DROP TABLE university_category');
$this->addSql('ALTER TABLE organisation ADD have_dorm TINYINT(1) DEFAULT \'0\' NOT NULL, ADD have_military_department TINYINT(1) DEFAULT \'0\' NOT NULL, DROP address');
$this->addSql('DROP INDEX IDX_EFBAC27D309D1878 ON university_category_relation');
$this->addSql('DROP INDEX IDX_EFBAC27D12469DE2 ON university_category_relation');
$this->addSql('ALTER TABLE university_category_relation DROP PRIMARY KEY');
$this->addSql('ALTER TABLE university_category_relation ADD organisation_id INT NOT NULL, ADD university_category_id INT NOT NULL, DROP university_id, DROP category_id');
$this->addSql('ALTER TABLE university_category_relation ADD CONSTRAINT FK_EFBAC27D21D6F15 FOREIGN KEY (university_category_id) REFERENCES university_categories (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE university_category_relation ADD CONSTRAINT FK_EFBAC27D9E6B1585 FOREIGN KEY (organisation_id) REFERENCES organisation (id) ON DELETE CASCADE');
$this->addSql('CREATE INDEX IDX_EFBAC27D9E6B1585 ON university_category_relation (organisation_id)');
$this->addSql('CREATE INDEX IDX_EFBAC27D21D6F15 ON university_category_relation (university_category_id)');
$this->addSql('ALTER TABLE university_category_relation ADD PRIMARY KEY (organisation_id, university_category_id)');
}
}