migrations/Version20210414071725.php line 1

Open in your IDE?
  1. <?php
  2. /**
  3.  * @license SILK SOFTWARE HOUSE SP Z O O
  4.  */
  5. declare(strict_types=1);
  6. namespace DoctrineMigrations;
  7. use Doctrine\DBAL\Schema\Schema;
  8. use Doctrine\Migrations\AbstractMigration;
  9. /**
  10.  * Auto-generated Migration: Please modify to your needs!
  11.  */
  12. final class Version20210414071725 extends AbstractMigration
  13. {
  14.     public function getDescription() : string
  15.     {
  16.         return '';
  17.     }
  18.     public function up(Schema $schema) : void
  19.     {
  20.         // this up() migration is auto-generated, please modify it to your needs
  21.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql''Migration can only be executed safely on \'postgresql\'.');
  22.         $this->addSql('CREATE SEQUENCE device_last_communication_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
  23.         $this->addSql('CREATE TABLE device_last_communication (id INT NOT NULL, device_id INT NOT NULL, last_command VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
  24.         $this->addSql('CREATE UNIQUE INDEX UNIQ_DDA2EEA994A4C7D4 ON device_last_communication (device_id)');
  25.         $this->addSql('ALTER TABLE device_last_communication ADD CONSTRAINT FK_DDA2EEA994A4C7D4 FOREIGN KEY (device_id) REFERENCES devices (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  26.     }
  27.     public function down(Schema $schema) : void
  28.     {
  29.         // this down() migration is auto-generated, please modify it to your needs
  30.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql''Migration can only be executed safely on \'postgresql\'.');
  31.         $this->addSql('CREATE SCHEMA public');
  32.         $this->addSql('DROP SEQUENCE device_last_communication_id_seq CASCADE');
  33.         $this->addSql('DROP TABLE device_last_communication');
  34.     }
  35. }