migrations/Version20260603120000.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 Version20260603120000 extends AbstractMigration
  7. {
  8.     public function getDescription(): string
  9.     {
  10.         return 'Add creator_push_notification table for in-app notification feed.';
  11.     }
  12.     public function up(Schema $schema): void
  13.     {
  14.         $this->addSql(
  15.             'CREATE TABLE creator_push_notification (
  16.                 id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL,
  17.                 creator_id BIGINT UNSIGNED NOT NULL,
  18.                 type VARCHAR(50) NOT NULL,
  19.                 title VARCHAR(255) DEFAULT NULL,
  20.                 body TEXT DEFAULT NULL,
  21.                 button_text VARCHAR(255) DEFAULT NULL,
  22.                 button_link VARCHAR(512) DEFAULT NULL,
  23.                 activity_id BIGINT UNSIGNED DEFAULT NULL,
  24.                 campaign_id BIGINT UNSIGNED DEFAULT NULL,
  25.                 payload JSON DEFAULT NULL,
  26.                 created_at DATETIME NOT NULL,
  27.                 INDEX idx_creator_created_at (creator_id, created_at),
  28.                 PRIMARY KEY(id)
  29.             ) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB',
  30.         );
  31.         $this->addSql(
  32.             'ALTER TABLE creator_push_notification ADD CONSTRAINT FK_creator_push_notification_creator FOREIGN KEY (creator_id) REFERENCES creator (id)',
  33.         );
  34.         $this->addSql(
  35.             'ALTER TABLE creator_push_notification ADD CONSTRAINT FK_creator_push_notification_activity FOREIGN KEY (activity_id) REFERENCES activity (id)',
  36.         );
  37.         $this->addSql(
  38.             'ALTER TABLE creator_push_notification ADD CONSTRAINT FK_creator_push_notification_campaign FOREIGN KEY (campaign_id) REFERENCES campaign (id)',
  39.         );
  40.     }
  41.     public function down(Schema $schema): void
  42.     {
  43.         $this->addSql('ALTER TABLE creator_push_notification DROP FOREIGN KEY FK_creator_push_notification_campaign');
  44.         $this->addSql('ALTER TABLE creator_push_notification DROP FOREIGN KEY FK_creator_push_notification_activity');
  45.         $this->addSql('ALTER TABLE creator_push_notification DROP FOREIGN KEY FK_creator_push_notification_creator');
  46.         $this->addSql('DROP TABLE creator_push_notification');
  47.     }
  48. }