migrations/Version20200420120825.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. /**
  7.  * Auto-generated Migration: Please modify to your needs!
  8.  */
  9. final class Version20200420120825 extends AbstractMigration
  10. {
  11.     public function getDescription() : string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema) : void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql''Migration can only be executed safely on \'postgresql\'.');
  19.         $this->addSql('CREATE SEQUENCE notifications_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
  20.         $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))');
  21.         $this->addSql('CREATE INDEX IDX_6000B0D3A76ED395 ON notifications (user_id)');
  22.         $this->addSql('CREATE INDEX IDX_6000B0D358FCEDE4 ON notifications (channel_setting_id)');
  23.         $this->addSql('COMMENT ON COLUMN notifications.strength_trigger IS \'Value that will trigger this notification.\'');
  24.         $this->addSql('COMMENT ON COLUMN notifications.triggered_at IS \'When was this notification triggered.\'');
  25.         $this->addSql('COMMENT ON COLUMN notifications.created_at IS \'Date of the entity creation. Should be fixed.\'');
  26.         $this->addSql('COMMENT ON COLUMN notifications.updated_at IS \'Date of the last change in entity. Shouldn’t be set to other dates.\'');
  27.         $this->addSql('ALTER TABLE notifications ADD CONSTRAINT FK_6000B0D3A76ED395 FOREIGN KEY (user_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  28.         $this->addSql('ALTER TABLE notifications ADD CONSTRAINT FK_6000B0D358FCEDE4 FOREIGN KEY (channel_setting_id) REFERENCES channel_settings (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  29.     }
  30.     public function down(Schema $schema) : void
  31.     {
  32.         // this down() migration is auto-generated, please modify it to your needs
  33.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql''Migration can only be executed safely on \'postgresql\'.');
  34.         $this->addSql('CREATE SCHEMA public');
  35.         $this->addSql('DROP SEQUENCE notifications_id_seq CASCADE');
  36.         $this->addSql('DROP TABLE notifications');
  37.     }
  38. }