<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20230831205127 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$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');
$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');
$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');
$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');
$this->addSql('ALTER TABLE std_notifications_schedule ADD CONSTRAINT FK_F8A2F88EBF5476CA FOREIGN KEY (notification) REFERENCES std_notifications (id)');
$this->addSql('ALTER TABLE std_notifications_schedule ADD CONSTRAINT FK_F8A2F88E8CDE5729 FOREIGN KEY (type) REFERENCES std_notifications_types (id)');
$this->addSql('ALTER TABLE std_notifications_schedule ADD CONSTRAINT FK_F8A2F88E451CDAD4 FOREIGN KEY (language_code) REFERENCES std_languages (language_code)');
$this->addSql('ALTER TABLE std_notifications_schedule_sent ADD CONSTRAINT FK_AC7C88B24991DBBC FOREIGN KEY (web_user) REFERENCES std_web_users (id)');
$this->addSql('ALTER TABLE std_notifications_schedule_sent ADD CONSTRAINT FK_AC7C88B2F28295E FOREIGN KEY (notification_schedule) REFERENCES std_notifications_schedule (id)');
$this->addSql('ALTER TABLE std_notifications_schedule_webusers ADD CONSTRAINT FK_88810764E328CBE FOREIGN KEY (push_notification_id) REFERENCES std_notifications_schedule (id)');
$this->addSql('ALTER TABLE std_notifications_schedule_webusers ADD CONSTRAINT FK_8881076DE12AB56 FOREIGN KEY (created_by) REFERENCES std_users (id)');
$this->addSql('ALTER TABLE std_notifications_schedule_webusers ADD CONSTRAINT FK_888107616FE72E1 FOREIGN KEY (updated_by) REFERENCES std_users (id)');
$this->addSql('ALTER TABLE std_notifications_schedule_webusers ADD CONSTRAINT FK_8881076A76ED395 FOREIGN KEY (user_id) REFERENCES std_web_users (id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE std_notifications_schedule DROP FOREIGN KEY FK_F8A2F88EBF5476CA');
$this->addSql('ALTER TABLE std_notifications_schedule DROP FOREIGN KEY FK_F8A2F88E8CDE5729');
$this->addSql('ALTER TABLE std_notifications_schedule DROP FOREIGN KEY FK_F8A2F88E451CDAD4');
$this->addSql('ALTER TABLE std_notifications_schedule_sent DROP FOREIGN KEY FK_AC7C88B24991DBBC');
$this->addSql('ALTER TABLE std_notifications_schedule_sent DROP FOREIGN KEY FK_AC7C88B2F28295E');
$this->addSql('ALTER TABLE std_notifications_schedule_webusers DROP FOREIGN KEY FK_88810764E328CBE');
$this->addSql('ALTER TABLE std_notifications_schedule_webusers DROP FOREIGN KEY FK_8881076DE12AB56');
$this->addSql('ALTER TABLE std_notifications_schedule_webusers DROP FOREIGN KEY FK_888107616FE72E1');
$this->addSql('ALTER TABLE std_notifications_schedule_webusers DROP FOREIGN KEY FK_8881076A76ED395');
$this->addSql('DROP TABLE std_notifications_schedule');
$this->addSql('DROP TABLE std_notifications_schedule_sent');
$this->addSql('DROP TABLE std_notifications_schedule_webusers');
$this->addSql('DROP TABLE std_notifications_types');
}
}