migrations/Version20221212155747.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. final class Version20221212155747 extends AbstractMigration
  7. {
  8.     public function getDescription(): string
  9.     {
  10.         return 'add new fields to mandate: period, exclusive duration , additional properties ';
  11.     }
  12.     public function up(Schema $schema): void
  13.     {
  14.         $this->addSql('ALTER TABLE mandate ADD duration INT DEFAULT NULL');
  15.         $this->addSql('ALTER TABLE mandate ADD exclusive_duration INT DEFAULT NULL');
  16.         $this->addSql('ALTER TABLE property ADD mandate_id INT DEFAULT NULL');
  17.         $this->addSql('ALTER TABLE property ADD CONSTRAINT FK_8BF21CDE6C1129CD FOREIGN KEY (mandate_id) REFERENCES mandate (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  18.         $this->addSql('CREATE INDEX IDX_8BF21CDE6C1129CD ON property (mandate_id)');
  19.     }
  20.     public function down(Schema $schema): void
  21.     {
  22.         $this->addSql('ALTER TABLE mandate DROP duration');
  23.         $this->addSql('ALTER TABLE mandate DROP exclusive_duration');
  24.         $this->addSql('ALTER TABLE property DROP CONSTRAINT FK_8BF21CDE6C1129CD');
  25.         $this->addSql('DROP INDEX IDX_8BF21CDE6C1129CD');
  26.         $this->addSql('ALTER TABLE property DROP mandate_id');
  27.     }
  28. }