<?php
declare(strict_types=1);
namespace PPSDKDoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20220323003431_SMSDeliveryRequests 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 sms_delivery_requests (id INT AUTO_INCREMENT NOT NULL, notification_definition_id INT DEFAULT NULL, user_id INT DEFAULT NULL, priority INT NOT NULL, phone_number VARCHAR(24) NOT NULL, message LONGTEXT NOT NULL, deliver_when DATETIME NOT NULL, abort_if_not_processed_when DATETIME DEFAULT NULL, delivery_status VARCHAR(16) NOT NULL, delivery_status_changed_when DATETIME DEFAULT NULL, delivery_status_comment LONGTEXT NOT NULL, created_when DATETIME NOT NULL, updated_when DATETIME NOT NULL, INDEX IDX_E140A21287AC63D8 (notification_definition_id), INDEX IDX_E140A212A76ED395 (user_id), INDEX delivery_plan (delivery_status, deliver_when, priority), INDEX abort_when (delivery_status, abort_if_not_processed_when), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE sms_delivery_requests ADD CONSTRAINT FK_E140A21287AC63D8 FOREIGN KEY (notification_definition_id) REFERENCES sms_notification_definitions (id)');
$this->addSql('ALTER TABLE sms_delivery_requests ADD CONSTRAINT FK_E140A212A76ED395 FOREIGN KEY (user_id) REFERENCES users (id)');
$this->addSql('ALTER TABLE sms_notification_definitions ADD delivery_can_continue_next_day TINYINT(1) DEFAULT 1 NOT NULL, ADD status_changed_when DATETIME DEFAULT NULL, ADD recipients LONGTEXT NOT NULL');
$this->addSql("UPDATE sms_notification_definitions SET recipients = '' WHERE recipients IS NULL");
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE sms_delivery_requests');
$this->addSql('ALTER TABLE sms_notification_definitions DROP delivery_can_continue_next_day, DROP status_changed_when, DROP recipients');
}
}