migrations/Version20230831205127.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 Version20230831205127 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('CREATE TABLE std_notifications_schedule (id INT UNSIGNED AUTO_INCREMENT NOT NULL COMMENT \'Notification schedule unique identifier\', notification INT UNSIGNED DEFAULT NULL COMMENT \'Notification unique identifier\', type INT UNSIGNED DEFAULT NULL COMMENT \'Notification type unique identifier\', language_code VARCHAR(2) DEFAULT NULL COMMENT \'ISO 639 Language code\', name VARCHAR(255) DEFAULT NULL COMMENT \'Notification schedule custom name\', description VARCHAR(255) DEFAULT NULL COMMENT \'Notification schedule custom description\', is_sent TINYINT(1) NOT NULL COMMENT \'Flag that indicates the Push Notification has been sended\', is_deleted TINYINT(1) NOT NULL COMMENT \'Flag that indicates the Push Notification has been deleted\', send_date DATETIME NOT NULL COMMENT \'Send date of the Push Notification\', link VARCHAR(255) DEFAULT NULL COMMENT \'Push Notification link\', send_all TINYINT(1) DEFAULT NULL COMMENT \'Flag that indicates the Push Notification is to send for all users\', created_by INT DEFAULT NULL, created_date DATETIME NOT NULL COMMENT \'Date and time of the record creation\', updated_by INT DEFAULT NULL, updated_date DATETIME NOT NULL COMMENT \'Date and time the record was last updated\', roles JSON DEFAULT NULL, INDEX fk_std_notifications_schedule_std_languages (language_code), INDEX fk_std_notifications_schedule_std_notifications (notification), INDEX fk_std_notifications_schedule_std_notifications_types (type), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  19.         $this->addSql('CREATE TABLE std_notifications_schedule_sent (id INT UNSIGNED AUTO_INCREMENT NOT NULL COMMENT \'Notification unique identifier\', web_user INT UNSIGNED DEFAULT NULL COMMENT \'Unique identifier\', notification_schedule INT UNSIGNED DEFAULT NULL COMMENT \'Notification schedule unique identifier\', is_viewed TINYINT(1) NOT NULL COMMENT \'Flag that indicates the notification has been viewed\', is_deleted TINYINT(1) NOT NULL COMMENT \'Flag that indicates the notification has been deleted\', created_by INT DEFAULT NULL, created_date DATETIME NOT NULL COMMENT \'Date and time of the record creation\', updated_by INT DEFAULT NULL, updated_date DATETIME NOT NULL COMMENT \'Date and time the record was last updated\', INDEX fk_std_notifications_schedule_sent_std_web_users (web_user), INDEX fk_std_notifications_schedule_sent_std_notifications_schedule (notification_schedule), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  20.         $this->addSql('CREATE TABLE std_notifications_schedule_webusers (push_notification_id INT UNSIGNED NOT NULL COMMENT \'Notification schedule unique identifier\', user_id INT UNSIGNED NOT NULL COMMENT \'Unique identifier\', created_by INT UNSIGNED DEFAULT NULL COMMENT \'Unique identifier\', updated_by INT UNSIGNED DEFAULT NULL COMMENT \'Unique identifier\', created_date DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL COMMENT \'Date and time of the record creation\', updated_date DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL COMMENT \'Date and time the record was last updated\', INDEX IDX_88810764E328CBE (push_notification_id), INDEX fk_std_notifications_schedule_webusers_std_users_0 (updated_by), INDEX fk_std_notifications_schedule_webusers_std_users_1 (created_by), INDEX fk_std_notifications_schedule_webusers_std_users (user_id), INDEX IDX_895AC1BBA76ED395 (user_id), PRIMARY KEY(push_notification_id, user_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  21.         $this->addSql('CREATE TABLE std_notifications_types (id INT UNSIGNED AUTO_INCREMENT NOT NULL COMMENT \'Notification type unique identifier\', name VARCHAR(100) NOT NULL COMMENT \'Notification type name\', machine_name VARCHAR(100) NOT NULL COMMENT \'Notification type machine name\', is_active TINYINT(1) DEFAULT 1 NOT NULL COMMENT \'Flag that indicates if the notification type is active\', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  22.         $this->addSql('ALTER TABLE std_notifications_schedule ADD CONSTRAINT FK_F8A2F88EBF5476CA FOREIGN KEY (notification) REFERENCES std_notifications (id)');
  23.         $this->addSql('ALTER TABLE std_notifications_schedule ADD CONSTRAINT FK_F8A2F88E8CDE5729 FOREIGN KEY (type) REFERENCES std_notifications_types (id)');
  24.         $this->addSql('ALTER TABLE std_notifications_schedule ADD CONSTRAINT FK_F8A2F88E451CDAD4 FOREIGN KEY (language_code) REFERENCES std_languages (language_code)');
  25.         $this->addSql('ALTER TABLE std_notifications_schedule_sent ADD CONSTRAINT FK_AC7C88B24991DBBC FOREIGN KEY (web_user) REFERENCES std_web_users (id)');
  26.         $this->addSql('ALTER TABLE std_notifications_schedule_sent ADD CONSTRAINT FK_AC7C88B2F28295E FOREIGN KEY (notification_schedule) REFERENCES std_notifications_schedule (id)');
  27.         $this->addSql('ALTER TABLE std_notifications_schedule_webusers ADD CONSTRAINT FK_88810764E328CBE FOREIGN KEY (push_notification_id) REFERENCES std_notifications_schedule (id)');
  28.         $this->addSql('ALTER TABLE std_notifications_schedule_webusers ADD CONSTRAINT FK_8881076DE12AB56 FOREIGN KEY (created_by) REFERENCES std_users (id)');
  29.         $this->addSql('ALTER TABLE std_notifications_schedule_webusers ADD CONSTRAINT FK_888107616FE72E1 FOREIGN KEY (updated_by) REFERENCES std_users (id)');
  30.         $this->addSql('ALTER TABLE std_notifications_schedule_webusers ADD CONSTRAINT FK_8881076A76ED395 FOREIGN KEY (user_id) REFERENCES std_web_users (id)');
  31.     }
  32.     public function down(Schema $schema): void
  33.     {
  34.         // this down() migration is auto-generated, please modify it to your needs
  35.         $this->addSql('ALTER TABLE std_notifications_schedule DROP FOREIGN KEY FK_F8A2F88EBF5476CA');
  36.         $this->addSql('ALTER TABLE std_notifications_schedule DROP FOREIGN KEY FK_F8A2F88E8CDE5729');
  37.         $this->addSql('ALTER TABLE std_notifications_schedule DROP FOREIGN KEY FK_F8A2F88E451CDAD4');
  38.         $this->addSql('ALTER TABLE std_notifications_schedule_sent DROP FOREIGN KEY FK_AC7C88B24991DBBC');
  39.         $this->addSql('ALTER TABLE std_notifications_schedule_sent DROP FOREIGN KEY FK_AC7C88B2F28295E');
  40.         $this->addSql('ALTER TABLE std_notifications_schedule_webusers DROP FOREIGN KEY FK_88810764E328CBE');
  41.         $this->addSql('ALTER TABLE std_notifications_schedule_webusers DROP FOREIGN KEY FK_8881076DE12AB56');
  42.         $this->addSql('ALTER TABLE std_notifications_schedule_webusers DROP FOREIGN KEY FK_888107616FE72E1');
  43.         $this->addSql('ALTER TABLE std_notifications_schedule_webusers DROP FOREIGN KEY FK_8881076A76ED395');
  44.         $this->addSql('DROP TABLE std_notifications_schedule');
  45.         $this->addSql('DROP TABLE std_notifications_schedule_sent');
  46.         $this->addSql('DROP TABLE std_notifications_schedule_webusers');
  47.         $this->addSql('DROP TABLE std_notifications_types');
  48.     }
  49. }