migrations/Version20210326114100.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 Version20210326114100 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 recipe_to_sync_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
  20.         $this->addSql('CREATE SEQUENCE device_command_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
  21.         $this->addSql('CREATE TABLE recipe_to_sync (id INT NOT NULL, recipe_id INT DEFAULT NULL, device_id INT DEFAULT NULL, schedule_date TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, priority INT DEFAULT NULL, PRIMARY KEY(id))');
  22.         $this->addSql('CREATE INDEX IDX_8721EAF559D8A214 ON recipe_to_sync (recipe_id)');
  23.         $this->addSql('CREATE INDEX IDX_8721EAF594A4C7D4 ON recipe_to_sync (device_id)');
  24.         $this->addSql('CREATE UNIQUE INDEX UNIQ_8721EAF562A6DC2794A4C7D459D8A214 ON recipe_to_sync (priority, device_id, recipe_id)');
  25.         $this->addSql('CREATE TABLE device_command (id INT NOT NULL, device_id INT NOT NULL, command VARCHAR(255) NOT NULL, priority INT DEFAULT 0 NOT NULL, PRIMARY KEY(id))');
  26.         $this->addSql('CREATE INDEX IDX_47C334994A4C7D4 ON device_command (device_id)');
  27.         $this->addSql('ALTER TABLE recipe_to_sync ADD CONSTRAINT FK_8721EAF559D8A214 FOREIGN KEY (recipe_id) REFERENCES recipes (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  28.         $this->addSql('ALTER TABLE recipe_to_sync ADD CONSTRAINT FK_8721EAF594A4C7D4 FOREIGN KEY (device_id) REFERENCES devices (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  29.         $this->addSql('ALTER TABLE device_command ADD CONSTRAINT FK_47C334994A4C7D4 FOREIGN KEY (device_id) REFERENCES devices (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  30.         $this->addSql('ALTER TABLE notifications ADD email VARCHAR(255) DEFAULT NULL');
  31.     }
  32.     public function down(Schema $schema) : void
  33.     {
  34.         // this down() migration is auto-generated, please modify it to your needs
  35.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql''Migration can only be executed safely on \'postgresql\'.');
  36.         $this->addSql('DROP SEQUENCE recipe_to_sync_id_seq CASCADE');
  37.         $this->addSql('DROP SEQUENCE device_command_id_seq CASCADE');
  38.         $this->addSql('DROP TABLE recipe_to_sync');
  39.         $this->addSql('DROP TABLE device_command');
  40.         $this->addSql('ALTER TABLE notifications DROP email');
  41.     }
  42. }