<?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 Version20220217131208 extends AbstractMigration
{
public function getDescription(): string
{
return 'add unit_id,is_commercial fields in project, add is_commercial field i task ';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE project ADD unit_id UUID DEFAULT NULL');
$this->addSql('ALTER TABLE project ADD is_commercial BOOLEAN DEFAULT \'true\'');
$this->addSql('UPDATE project SET is_commercial = true');
$this->addSql('COMMENT ON COLUMN project.unit_id IS \'(DC2Type:uuid)\'');
$this->addSql('ALTER TABLE project ADD CONSTRAINT FK_2FB3D0EEF8BD700D FOREIGN KEY (unit_id) REFERENCES unit (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX IDX_2FB3D0EEF8BD700D ON project (unit_id)');
$this->addSql('ALTER TABLE project ALTER is_commercial SET NOT NULL');
$this->addSql('ALTER TABLE task ADD is_commercial BOOLEAN DEFAULT \'true\' NOT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE project DROP CONSTRAINT FK_2FB3D0EEF8BD700D');
$this->addSql('DROP INDEX IDX_2FB3D0EEF8BD700D');
$this->addSql('ALTER TABLE project DROP unit_id');
$this->addSql('ALTER TABLE project DROP is_commercial');
$this->addSql('ALTER TABLE task DROP is_commercial');
}
}