<?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 Version20240604103251 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function isTransactional(): bool
{
return false;
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE customer_notification (id INT AUTO_INCREMENT NOT NULL, customer_id INT DEFAULT NULL, subject VARCHAR(255) NOT NULL, content LONGTEXT NOT NULL, is_read TINYINT(1) NOT NULL, extra JSON DEFAULT NULL, type INT NOT NULL, hash VARCHAR(255) NOT NULL, cdate DATETIME NOT NULL, UNIQUE INDEX UNIQ_B18CB5D3D1B862B8 (hash), INDEX IDX_B18CB5D39395C3F3 (customer_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE notification (id INT AUTO_INCREMENT NOT NULL, alias VARCHAR(255) DEFAULT NULL, subject VARCHAR(255) NOT NULL, content LONGTEXT NOT NULL, date_to_send DATETIME DEFAULT NULL, date_last_sent DATETIME DEFAULT NULL, hash VARCHAR(255) NOT NULL, status INT NOT NULL, is_removed TINYINT(1) NOT NULL, cdate DATETIME NOT NULL, mdate DATETIME DEFAULT NULL, type INT NOT NULL, UNIQUE INDEX UNIQ_BF5476CAD1B862B8 (hash), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE notification_customer_assigned (notification_id INT NOT NULL, customer_id INT NOT NULL, INDEX IDX_E4D90554EF1A9D84 (notification_id), INDEX IDX_E4D905549395C3F3 (customer_id), PRIMARY KEY(notification_id, customer_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE notification_tag_assigned (notification_id INT NOT NULL, tag_id INT NOT NULL, INDEX IDX_3CA55D74EF1A9D84 (notification_id), INDEX IDX_3CA55D74BAD26311 (tag_id), PRIMARY KEY(notification_id, tag_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE notification_subscription_assigned (notification_id INT NOT NULL, service_id INT NOT NULL, INDEX IDX_81E1877AEF1A9D84 (notification_id), INDEX IDX_81E1877AED5CA9E6 (service_id), PRIMARY KEY(notification_id, service_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE notification_service_assigned (notification_id INT NOT NULL, service_id INT NOT NULL, INDEX IDX_78E8D75AEF1A9D84 (notification_id), INDEX IDX_78E8D75AED5CA9E6 (service_id), PRIMARY KEY(notification_id, service_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE customer_notification ADD CONSTRAINT FK_B18CB5D39395C3F3 FOREIGN KEY (customer_id) REFERENCES customer (id)');
$this->addSql('ALTER TABLE notification_customer_assigned ADD CONSTRAINT FK_E4D90554EF1A9D84 FOREIGN KEY (notification_id) REFERENCES notification (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE notification_customer_assigned ADD CONSTRAINT FK_E4D905549395C3F3 FOREIGN KEY (customer_id) REFERENCES customer (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE notification_tag_assigned ADD CONSTRAINT FK_3CA55D74EF1A9D84 FOREIGN KEY (notification_id) REFERENCES notification (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE notification_tag_assigned ADD CONSTRAINT FK_3CA55D74BAD26311 FOREIGN KEY (tag_id) REFERENCES tag (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE notification_subscription_assigned ADD CONSTRAINT FK_81E1877AEF1A9D84 FOREIGN KEY (notification_id) REFERENCES notification (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE notification_subscription_assigned ADD CONSTRAINT FK_81E1877AED5CA9E6 FOREIGN KEY (service_id) REFERENCES service (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE notification_service_assigned ADD CONSTRAINT FK_78E8D75AEF1A9D84 FOREIGN KEY (notification_id) REFERENCES notification (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE notification_service_assigned ADD CONSTRAINT FK_78E8D75AED5CA9E6 FOREIGN KEY (service_id) REFERENCES service (id) ON DELETE CASCADE');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE notification_customer_assigned DROP FOREIGN KEY FK_E4D90554EF1A9D84');
$this->addSql('ALTER TABLE notification_tag_assigned DROP FOREIGN KEY FK_3CA55D74EF1A9D84');
$this->addSql('ALTER TABLE notification_subscription_assigned DROP FOREIGN KEY FK_81E1877AEF1A9D84');
$this->addSql('ALTER TABLE notification_service_assigned DROP FOREIGN KEY FK_78E8D75AEF1A9D84');
$this->addSql('DROP TABLE customer_notification');
$this->addSql('DROP TABLE notification');
$this->addSql('DROP TABLE notification_customer_assigned');
$this->addSql('DROP TABLE notification_tag_assigned');
$this->addSql('DROP TABLE notification_subscription_assigned');
$this->addSql('DROP TABLE notification_service_assigned');
}
}