migrations/Version20201104091017.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 Version20201104091017 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return 'Add \'contractor\' table';
  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 contractor (id UUID NOT NULL, short_name VARCHAR(255) NOT NULL, full_name VARCHAR(500) DEFAULT NULL, PRIMARY KEY(id))');
  19.         $this->addSql('COMMENT ON COLUMN contractor.id IS \'(DC2Type:uuid)\'');
  20.         $this->addSql('ALTER TABLE project ADD contractor_id UUID DEFAULT NULL');
  21.         $this->addSql('ALTER TABLE project DROP contractor');
  22.         $this->addSql('COMMENT ON COLUMN project.contractor_id IS \'(DC2Type:uuid)\'');
  23.         $this->addSql('ALTER TABLE project ADD CONSTRAINT FK_2FB3D0EEB0265DC7 FOREIGN KEY (contractor_id) REFERENCES contractor (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  24.         $this->addSql('CREATE INDEX IDX_2FB3D0EEB0265DC7 ON project (contractor_id)');
  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('ALTER TABLE project DROP CONSTRAINT FK_2FB3D0EEB0265DC7');
  30.         $this->addSql('DROP TABLE contractor');
  31.         $this->addSql('DROP INDEX IDX_2FB3D0EEB0265DC7');
  32.         $this->addSql('ALTER TABLE project ADD contractor VARCHAR(255) DEFAULT NULL');
  33.         $this->addSql('ALTER TABLE project DROP contractor_id');
  34.     }
  35. }