<?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 Version20180919164930 extends AbstractMigration
{
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('DROP TABLE notifications');
$this->addSql('
CREATE TABLE notification (
id INT AUTO_INCREMENT NOT NULL,
user_id INT DEFAULT NULL,
actor_id INT DEFAULT NULL,
customer_id INT DEFAULT NULL,
comment_id INT DEFAULT NULL,
message_id INT DEFAULT NULL,
file_id INT DEFAULT NULL,
upsell_request_id INT DEFAULT NULL,
lead_id INT DEFAULT NULL,
event_id INT DEFAULT NULL,
issue_id INT DEFAULT NULL,
feed_id INT DEFAULT NULL,
command ENUM(\'created_object\', \'created_comment\', \'assigned_customer\', \'assigned_lead\', \'assigned_event\', \'assigned_issue\', \'assigned_feed\', \'event_poked\', \'event_reminder\', \'event_is_due\', \'message_sent\') NOT NULL COMMENT \'(DC2Type:NotificationCommandType)\',
params LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:array)\',
unread TINYINT(1) NOT NULL,
created_at DATETIME NOT NULL,
type ENUM(\'system\', \'customer\', \'customer_comment\', \'customer_message\', \'customer_file\', \'customer_upsell_request\', \'lead\', \'event\', \'issue\', \'feed\') NOT NULL COMMENT \'(DC2Type:NotificationSectionType)\',
INDEX IDX_BF5476CAA76ED395 (user_id),
INDEX IDX_BF5476CA10DAF24A (actor_id),
INDEX IDX_BF5476CA9395C3F3 (customer_id),
INDEX IDX_BF5476CAF8697D13 (comment_id),
INDEX IDX_BF5476CA537A1329 (message_id),
INDEX IDX_BF5476CA93CB796C (file_id),
INDEX IDX_BF5476CA6A6F8AD7 (upsell_request_id),
INDEX IDX_BF5476CA55458D (lead_id),
INDEX IDX_BF5476CA71F7E88B (event_id),
INDEX IDX_BF5476CA5E7AA58C (issue_id),
INDEX IDX_BF5476CA51A5BC03 (feed_id),
PRIMARY KEY(id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB
');
$this->addSql('ALTER TABLE notification ADD CONSTRAINT FK_BF5476CAA76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE notification ADD CONSTRAINT FK_BF5476CA10DAF24A FOREIGN KEY (actor_id) REFERENCES user (id) ON DELETE SET NULL');
$this->addSql('ALTER TABLE notification ADD CONSTRAINT FK_BF5476CA9395C3F3 FOREIGN KEY (customer_id) REFERENCES customer (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE notification ADD CONSTRAINT FK_BF5476CAF8697D13 FOREIGN KEY (comment_id) REFERENCES customer_comment (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE notification ADD CONSTRAINT FK_BF5476CA537A1329 FOREIGN KEY (message_id) REFERENCES customer_message (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE notification ADD CONSTRAINT FK_BF5476CA93CB796C FOREIGN KEY (file_id) REFERENCES customer_file (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE notification ADD CONSTRAINT FK_BF5476CA6A6F8AD7 FOREIGN KEY (upsell_request_id) REFERENCES customer_upsell_request (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE notification ADD CONSTRAINT FK_BF5476CA55458D FOREIGN KEY (lead_id) REFERENCES lead (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE notification ADD CONSTRAINT FK_BF5476CA71F7E88B FOREIGN KEY (event_id) REFERENCES event (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE notification ADD CONSTRAINT FK_BF5476CA5E7AA58C FOREIGN KEY (issue_id) REFERENCES issue (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE notification ADD CONSTRAINT FK_BF5476CA51A5BC03 FOREIGN KEY (feed_id) REFERENCES feed (id) ON DELETE CASCADE');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('DROP TABLE notification');
$this->addSql('
CREATE TABLE notifications (
id INT AUTO_INCREMENT NOT NULL,
administrators_id INT NOT NULL,
object_name VARCHAR(255) DEFAULT NULL COLLATE latin1_swedish_ci,
object_id INT NOT NULL,
parameters LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:array)\',
date_added DATETIME DEFAULT NULL,
last_modified DATETIME DEFAULT NULL,
INDEX idx_administrators_id (administrators_id),
INDEX idx_object (object_name, object_id),
PRIMARY KEY(id)
) DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ENGINE = MyISAM
');
}
}