migrations/Version20220217131208.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 Version20220217131208 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return 'add unit_id,is_commercial fields in project, add is_commercial field i task ';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         $this->addSql('ALTER TABLE project ADD unit_id UUID DEFAULT NULL');
  18.         $this->addSql('ALTER TABLE project ADD is_commercial BOOLEAN DEFAULT \'true\'');
  19.         $this->addSql('UPDATE project SET is_commercial = true');
  20.         $this->addSql('COMMENT ON COLUMN project.unit_id IS \'(DC2Type:uuid)\'');
  21.         $this->addSql('ALTER TABLE project ADD CONSTRAINT FK_2FB3D0EEF8BD700D FOREIGN KEY (unit_id) REFERENCES unit (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  22.         $this->addSql('CREATE INDEX IDX_2FB3D0EEF8BD700D ON project (unit_id)');
  23.         $this->addSql('ALTER TABLE project ALTER is_commercial SET NOT NULL');
  24.         $this->addSql('ALTER TABLE task ADD is_commercial BOOLEAN DEFAULT \'true\' NOT NULL');
  25.     }
  26.     public function down(Schema $schema): void
  27.     {
  28.         $this->addSql('ALTER TABLE project DROP CONSTRAINT FK_2FB3D0EEF8BD700D');
  29.         $this->addSql('DROP INDEX IDX_2FB3D0EEF8BD700D');
  30.         $this->addSql('ALTER TABLE project DROP unit_id');
  31.         $this->addSql('ALTER TABLE project DROP is_commercial');
  32.         $this->addSql('ALTER TABLE task DROP is_commercial');
  33.     }
  34. }