<?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 Version20200326132937 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 licences_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE licences (id INT NOT NULL, device_id INT NOT NULL, customer_id INT NOT NULL, licensed_from TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, licensed_to TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, note TEXT 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_6314AC4F94A4C7D4 ON licences (device_id)');
$this->addSql('CREATE INDEX IDX_6314AC4F9395C3F3 ON licences (customer_id)');
$this->addSql('COMMENT ON COLUMN licences.licensed_from IS \'When this license starts.\'');
$this->addSql('COMMENT ON COLUMN licences.licensed_to IS \'When this license ends.\'');
$this->addSql('COMMENT ON COLUMN licences.note IS \'Note about customer.\'');
$this->addSql('COMMENT ON COLUMN licences.created_at IS \'Date of the entity creation. Should be fixed.\'');
$this->addSql('COMMENT ON COLUMN licences.updated_at IS \'Date of the last change in entity. Shouldn’t be set to other dates.\'');
$this->addSql('ALTER TABLE licences ADD CONSTRAINT FK_6314AC4F94A4C7D4 FOREIGN KEY (device_id) REFERENCES devices (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE licences ADD CONSTRAINT FK_6314AC4F9395C3F3 FOREIGN KEY (customer_id) REFERENCES customers (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 licences_id_seq CASCADE');
$this->addSql('DROP TABLE licences');
}
}