Version20211122072414   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 39
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A down() 0 5 1
A up() 0 19 1
A getDbName() 0 3 1
A getDescription() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DoctrineMigrations;
6
7
use App\Infrastructure\Doctrine\Migrations\DoctrineMigration;
8
use Doctrine\DBAL\Schema\Schema;
9
10
final class Version20211122072414 extends DoctrineMigration
11
{
12
    public function getDescription(): string
13
    {
14
        return '';
15
    }
16
17
    public function up(Schema $schema): void
18
    {
19
        $this->addSql('CREATE TABLE POST_HEADERS (id BLOB NOT NULL --(DC2Type:ulid)
20
        , title VARCHAR(255) NOT NULL, summary VARCHAR(255) NOT NULL, commentsCount INTEGER NOT NULL, createdById BLOB NOT NULL --(DC2Type:ulid)
21
        , createdByName VARCHAR(255) NOT NULL, createdAt DATETIME NOT NULL, version INTEGER NOT NULL, flatTags CLOB NOT NULL --(DC2Type:json)
22
        , PRIMARY KEY(id))');
23
        $this->addSql('CREATE TABLE TAGS (id BLOB NOT NULL --(DC2Type:ulid)
24
        , tag VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
25
        $this->addSql('CREATE UNIQUE INDEX UNIQ_T1 ON TAGS (tag)');
26
        $this->addSql('CREATE TABLE TAGS_POSTS (tagId BLOB NOT NULL --(DC2Type:ulid)
27
        , postId BLOB NOT NULL --(DC2Type:ulid)
28
        , PRIMARY KEY(tagId, postId)
29
        , FOREIGN KEY(tagId) REFERENCES TAGS(id)
30
        , FOREIGN KEY(postId) REFERENCES POST_HEADERS(id))
31
        
32
        ');
33
        $this->addSql('CREATE INDEX IDX_TP1 ON TAGS_POSTS (tagId)');
34
        $this->addSql('CREATE INDEX IDX_TP2 ON TAGS_POSTS (postId)');
35
        $this->addSql('CREATE INDEX IDX_TP3 ON TAGS_POSTS (tagId, postId)');
36
    }
37
38
    public function down(Schema $schema): void
39
    {
40
        $this->addSql('DROP TABLE TAGS_POSTS');
41
        $this->addSql('DROP TABLE POST_HEADERS');
42
        $this->addSql('DROP TABLE TAGS');
43
44
    }
45
46
    protected function getDbName(): string
47
    {
48
        return "tags";
49
    }
50
}
51