migrations/Version20250909154841.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 Version20250909154841 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('ALTER TABLE owner_contact DROP FOREIGN KEY FK_C01460E77E3C61F9');
  19.         $this->addSql('ALTER TABLE owner_contact DROP FOREIGN KEY FK_C01460E7E7A1254A');
  20.         $this->addSql('DROP TABLE owner_contact');
  21.         $this->addSql('ALTER TABLE owner DROP FOREIGN KEY FK_CF60E67CD905C92C');
  22.         $this->addSql('DROP INDEX UNIQ_CF60E67CD905C92C ON owner');
  23.         $this->addSql('ALTER TABLE owner DROP primary_contact_id');
  24.     }
  25.     public function down(Schema $schema): void
  26.     {
  27.         // this down() migration is auto-generated, please modify it to your needs
  28.         $this->addSql('CREATE TABLE owner_contact (owner_id CHAR(36) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci` COMMENT \'(DC2Type:uuid)\', contact_id CHAR(36) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci` COMMENT \'(DC2Type:uuid)\', UNIQUE INDEX UNIQ_C01460E7E7A1254A (contact_id), INDEX IDX_C01460E77E3C61F9 (owner_id), PRIMARY KEY(owner_id, contact_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
  29.         $this->addSql('ALTER TABLE owner_contact ADD CONSTRAINT FK_C01460E77E3C61F9 FOREIGN KEY (owner_id) REFERENCES owner (id) ON UPDATE NO ACTION ON DELETE CASCADE');
  30.         $this->addSql('ALTER TABLE owner_contact ADD CONSTRAINT FK_C01460E7E7A1254A FOREIGN KEY (contact_id) REFERENCES contact (id) ON UPDATE NO ACTION ON DELETE NO ACTION');
  31.         $this->addSql('ALTER TABLE owner ADD primary_contact_id CHAR(36) DEFAULT NULL COMMENT \'(DC2Type:uuid)\'');
  32.         $this->addSql('ALTER TABLE owner ADD CONSTRAINT FK_CF60E67CD905C92C FOREIGN KEY (primary_contact_id) REFERENCES contact (id) ON UPDATE NO ACTION ON DELETE NO ACTION');
  33.         $this->addSql('CREATE UNIQUE INDEX UNIQ_CF60E67CD905C92C ON owner (primary_contact_id)');
  34.     }
  35. }