migrations/Version20200326132937.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 Version20200326132937 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 licences_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
  20.         $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))');
  21.         $this->addSql('CREATE INDEX IDX_6314AC4F94A4C7D4 ON licences (device_id)');
  22.         $this->addSql('CREATE INDEX IDX_6314AC4F9395C3F3 ON licences (customer_id)');
  23.         $this->addSql('COMMENT ON COLUMN licences.licensed_from IS \'When this license starts.\'');
  24.         $this->addSql('COMMENT ON COLUMN licences.licensed_to IS \'When this license ends.\'');
  25.         $this->addSql('COMMENT ON COLUMN licences.note IS \'Note about customer.\'');
  26.         $this->addSql('COMMENT ON COLUMN licences.created_at IS \'Date of the entity creation. Should be fixed.\'');
  27.         $this->addSql('COMMENT ON COLUMN licences.updated_at IS \'Date of the last change in entity. Shouldn’t be set to other dates.\'');
  28.         $this->addSql('ALTER TABLE licences ADD CONSTRAINT FK_6314AC4F94A4C7D4 FOREIGN KEY (device_id) REFERENCES devices (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  29.         $this->addSql('ALTER TABLE licences ADD CONSTRAINT FK_6314AC4F9395C3F3 FOREIGN KEY (customer_id) REFERENCES customers (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  30.     }
  31.     public function down(Schema $schema) : void
  32.     {
  33.         // this down() migration is auto-generated, please modify it to your needs
  34.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql''Migration can only be executed safely on \'postgresql\'.');
  35.         $this->addSql('CREATE SCHEMA public');
  36.         $this->addSql('DROP SEQUENCE licences_id_seq CASCADE');
  37.         $this->addSql('DROP TABLE licences');
  38.     }
  39. }