<?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 Version20200420120825 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->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('CREATE SEQUENCE notifications_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE notifications (id INT NOT NULL, user_id INT NOT NULL, channel_setting_id INT NOT NULL, strength_trigger DOUBLE PRECISION NOT NULL, triggered_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, created_at TIMESTAMP(0) WITH TIME ZONE DEFAULT NULL, updated_at TIMESTAMP(0) WITH TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_6000B0D3A76ED395 ON notifications (user_id)');
$this->addSql('CREATE INDEX IDX_6000B0D358FCEDE4 ON notifications (channel_setting_id)');
$this->addSql('COMMENT ON COLUMN notifications.strength_trigger IS \'Value that will trigger this notification.\'');
$this->addSql('COMMENT ON COLUMN notifications.triggered_at IS \'When was this notification triggered.\'');
$this->addSql('COMMENT ON COLUMN notifications.created_at IS \'Date of the entity creation. Should be fixed.\'');
$this->addSql('COMMENT ON COLUMN notifications.updated_at IS \'Date of the last change in entity. Shouldn’t be set to other dates.\'');
$this->addSql('ALTER TABLE notifications ADD CONSTRAINT FK_6000B0D3A76ED395 FOREIGN KEY (user_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE notifications ADD CONSTRAINT FK_6000B0D358FCEDE4 FOREIGN KEY (channel_setting_id) REFERENCES channel_settings (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('CREATE SCHEMA public');
$this->addSql('DROP SEQUENCE notifications_id_seq CASCADE');
$this->addSql('DROP TABLE notifications');
}
}