<?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 Version20210326114100 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 recipe_to_sync_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE device_command_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$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))');
$this->addSql('CREATE INDEX IDX_8721EAF559D8A214 ON recipe_to_sync (recipe_id)');
$this->addSql('CREATE INDEX IDX_8721EAF594A4C7D4 ON recipe_to_sync (device_id)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_8721EAF562A6DC2794A4C7D459D8A214 ON recipe_to_sync (priority, device_id, recipe_id)');
$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))');
$this->addSql('CREATE INDEX IDX_47C334994A4C7D4 ON device_command (device_id)');
$this->addSql('ALTER TABLE recipe_to_sync ADD CONSTRAINT FK_8721EAF559D8A214 FOREIGN KEY (recipe_id) REFERENCES recipes (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE recipe_to_sync ADD CONSTRAINT FK_8721EAF594A4C7D4 FOREIGN KEY (device_id) REFERENCES devices (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE device_command ADD CONSTRAINT FK_47C334994A4C7D4 FOREIGN KEY (device_id) REFERENCES devices (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE notifications ADD email VARCHAR(255) DEFAULT NULL');
}
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('DROP SEQUENCE recipe_to_sync_id_seq CASCADE');
$this->addSql('DROP SEQUENCE device_command_id_seq CASCADE');
$this->addSql('DROP TABLE recipe_to_sync');
$this->addSql('DROP TABLE device_command');
$this->addSql('ALTER TABLE notifications DROP email');
}
}