migrations/Version20220419132503.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 Version20220419132503 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 department (id INT NOT NULL, PRIMARY KEY(id))');
  19.         $this->addSql('CREATE TABLE department_position_rel (department_id INT NOT NULL, position_id INT NOT NULL, PRIMARY KEY(department_id, position_id))');
  20.         $this->addSql('CREATE INDEX IDX_FB71BD67AE80F5DF ON department_position_rel (department_id)');
  21.         $this->addSql('CREATE INDEX IDX_FB71BD67DD842E46 ON department_position_rel (position_id)');
  22.         $this->addSql('CREATE TABLE position (id INT NOT NULL, PRIMARY KEY(id))');
  23.         $this->addSql('ALTER TABLE department_position_rel ADD CONSTRAINT FK_FB71BD67AE80F5DF FOREIGN KEY (department_id) REFERENCES department (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  24.         $this->addSql('ALTER TABLE department_position_rel ADD CONSTRAINT FK_FB71BD67DD842E46 FOREIGN KEY (position_id) REFERENCES position (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  25.     }
  26.     public function down(Schema $schema): void
  27.     {
  28.         // this down() migration is auto-generated, please modify it to your needs
  29.         $this->addSql('CREATE SCHEMA public');
  30.         $this->addSql('ALTER TABLE department_position_rel DROP CONSTRAINT FK_FB71BD67AE80F5DF');
  31.         $this->addSql('ALTER TABLE department_position_rel DROP CONSTRAINT FK_FB71BD67DD842E46');
  32.         $this->addSql('DROP TABLE department');
  33.         $this->addSql('DROP TABLE department_position_rel');
  34.         $this->addSql('DROP TABLE position');
  35.     }
  36. }