Passed
Branch feature/tags (cc2dab)
by Stone
06:13
created

Version20190308130516   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 15
dl 0
loc 30
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDescription() 0 3 1
A up() 0 11 1
A down() 0 10 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DoctrineMigrations;
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 Version20190308130516 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() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
24
25
        $this->addSql('CREATE TABLE tag (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, slug VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_389B7835E237E06 (name), UNIQUE INDEX UNIQ_389B783989D9B62 (slug), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
26
        $this->addSql('CREATE TABLE trick_tag (trick_id INT NOT NULL, tag_id INT NOT NULL, INDEX IDX_B4395361B281BE2E (trick_id), INDEX IDX_B4395361BAD26311 (tag_id), PRIMARY KEY(trick_id, tag_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
27
        $this->addSql('ALTER TABLE trick_tag ADD CONSTRAINT FK_B4395361B281BE2E FOREIGN KEY (trick_id) REFERENCES trick (id) ON DELETE CASCADE');
28
        $this->addSql('ALTER TABLE trick_tag ADD CONSTRAINT FK_B4395361BAD26311 FOREIGN KEY (tag_id) REFERENCES tag (id) ON DELETE CASCADE');
29
        $this->addSql('ALTER TABLE user CHANGE roles roles JSON NOT NULL');
30
        $this->addSql('ALTER TABLE ext_log_entries CHANGE object_id object_id VARCHAR(64) DEFAULT NULL, CHANGE data data LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:array)\', CHANGE username username VARCHAR(255) DEFAULT NULL');
31
    }
32
33
    public function down(Schema $schema) : void
34
    {
35
        // this down() migration is auto-generated, please modify it to your needs
36
        $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
37
38
        $this->addSql('ALTER TABLE trick_tag DROP FOREIGN KEY FK_B4395361BAD26311');
39
        $this->addSql('DROP TABLE tag');
40
        $this->addSql('DROP TABLE trick_tag');
41
        $this->addSql('ALTER TABLE ext_log_entries CHANGE object_id object_id VARCHAR(64) DEFAULT \'\'NULL\'\' COLLATE utf8_unicode_ci, CHANGE data data LONGTEXT DEFAULT \'\'NULL\'\' COLLATE utf8_unicode_ci COMMENT \'(DC2Type:array)\', CHANGE username username VARCHAR(255) DEFAULT \'\'NULL\'\' COLLATE utf8_unicode_ci');
42
        $this->addSql('ALTER TABLE user CHANGE roles roles LONGTEXT NOT NULL COLLATE utf8mb4_bin');
43
    }
44
}
45