Version20190316131700::getDescription()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Migrations;
6
7
use Doctrine\DBAL\Schema\Schema;
8
use Doctrine\Migrations\AbstractMigration;
9
10
/**
11
 * Auto-generated Migration: Please modify to your needs!
12
 */
13
final class Version20190316131700 extends AbstractMigration
14
{
15
    public function getDescription() : string
16
    {
17
        return '';
18
    }
19
20
    public function up(Schema $schema) : void
21
    {
22
        // this up() migration is auto-generated, please modify it to your needs
23
        $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
24
25
        $this->addSql('CREATE TABLE npd_lesson (
26
          uuid UUID NOT NULL, 
27
          module_id UUID NOT NULL, 
28
          title VARCHAR(255) NOT NULL, 
29
          description TEXT NOT NULL, 
30
          embed_code TEXT NOT NULL, 
31
          created TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, 
32
          updated TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, 
33
          position INT DEFAULT 0 NOT NULL, 
34
          PRIMARY KEY(uuid)
35
        )');
36
        $this->addSql('CREATE INDEX IDX_148D7D2FAFC2B591 ON npd_lesson (module_id)');
37
        $this->addSql('COMMENT ON COLUMN npd_lesson.uuid IS \'(DC2Type:uuid)\'');
38
        $this->addSql('COMMENT ON COLUMN npd_lesson.module_id IS \'(DC2Type:uuid)\'');
39
        $this->addSql('ALTER TABLE 
40
          npd_lesson 
41
        ADD 
42
          CONSTRAINT FK_148D7D2FAFC2B591 FOREIGN KEY (module_id) REFERENCES npd_module (uuid) NOT DEFERRABLE INITIALLY IMMEDIATE');
43
    }
44
45
    public function down(Schema $schema) : void
46
    {
47
        // this down() migration is auto-generated, please modify it to your needs
48
        $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
49
50
        $this->addSql('CREATE SCHEMA public');
51
        $this->addSql('DROP TABLE npd_lesson');
52
    }
53
}
54