<?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 Version20230214173532 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 notification (id INT AUTO_INCREMENT NOT NULL, title VARCHAR(255) NOT NULL, body LONGTEXT DEFAULT NULL, level VARCHAR(30) DEFAULT NULL, send_email TINYINT(1) DEFAULT NULL, targets LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\', valid_from DATETIME NOT NULL, valid_to DATETIME NOT NULL, status SMALLINT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE notification_customer (notification_id INT NOT NULL, customer_id INT NOT NULL, INDEX IDX_D429B6ACEF1A9D84 (notification_id), INDEX IDX_D429B6AC9395C3F3 (customer_id), PRIMARY KEY(notification_id, customer_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE notification_user_consent (notification_id INT NOT NULL, user_consent_id INT NOT NULL, INDEX IDX_3A11FC2FEF1A9D84 (notification_id), INDEX IDX_3A11FC2FE6605B8F (user_consent_id), PRIMARY KEY(notification_id, user_consent_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE notification_customer ADD CONSTRAINT FK_D429B6ACEF1A9D84 FOREIGN KEY (notification_id) REFERENCES notification (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE notification_customer ADD CONSTRAINT FK_D429B6AC9395C3F3 FOREIGN KEY (customer_id) REFERENCES customer (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE notification_user_consent ADD CONSTRAINT FK_3A11FC2FEF1A9D84 FOREIGN KEY (notification_id) REFERENCES notification (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE notification_user_consent ADD CONSTRAINT FK_3A11FC2FE6605B8F FOREIGN KEY (user_consent_id) REFERENCES user_consent (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE user_consent ADD last_login DATETIME DEFAULT NULL, ADD google_id VARCHAR(50) NOT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE notification_customer DROP FOREIGN KEY FK_D429B6ACEF1A9D84');
$this->addSql('ALTER TABLE notification_customer DROP FOREIGN KEY FK_D429B6AC9395C3F3');
$this->addSql('ALTER TABLE notification_user_consent DROP FOREIGN KEY FK_3A11FC2FEF1A9D84');
$this->addSql('ALTER TABLE notification_user_consent DROP FOREIGN KEY FK_3A11FC2FE6605B8F');
$this->addSql('DROP TABLE notification');
$this->addSql('DROP TABLE notification_customer');
$this->addSql('DROP TABLE notification_user_consent');
$this->addSql('ALTER TABLE user_consent DROP last_login, DROP google_id');
}
}