migrations/Version20250324122956.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 Version20250324122956 extends AbstractMigration
  7. {
  8.     public function getDescription(): string
  9.     {
  10.         return 'Update webhook to manage multiple source & add fields entity and entity_id to manage sync';
  11.     }
  12.     public function up(Schema $schema): void
  13.     {
  14.         $this->addSql('ALTER TABLE notification ADD entity VARCHAR(255) DEFAULT NULL, ADD entity_id INT DEFAULT NULL');
  15.         $this->addSql('ALTER TABLE webhook DROP INDEX UNIQ_8A741756953C1C61, ADD INDEX IDX_8A741756953C1C61 (source_id)');
  16.         $this->addSql('ALTER TABLE webhook ADD object VARCHAR(255) NOT NULL');
  17.         $this->addSql('CREATE UNIQUE INDEX source_object ON webhook (source_id, object)');
  18.         $this->addSql('UPDATE webhook SET object = "order"');
  19.     }
  20.     public function down(Schema $schema): void
  21.     {
  22.         $this->addSql('ALTER TABLE notification DROP entity, DROP entity_id');
  23.         $this->addSql('ALTER TABLE `webhook` DROP INDEX IDX_8A741756953C1C61, ADD UNIQUE INDEX UNIQ_8A741756953C1C61 (source_id)');
  24.         $this->addSql('DROP INDEX source_object ON `webhook`');
  25.         $this->addSql('ALTER TABLE `webhook` DROP object');
  26.     }
  27. }