Completed
Pull Request — development (#495)
by Mirco
08:08
created

Version20170516084212::up()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 33
Code Lines 7

Duplication

Lines 33
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 1
b 0
f 0
nc 1
nop 1
dl 33
loc 33
rs 8.8571
1
<?php
2
3
namespace Application\Migrations;
4
5
use Doctrine\DBAL\Migrations\AbstractMigration;
6
use Doctrine\DBAL\Schema\Schema;
7
8
/**
9
 * Auto-generated Migration: Please modify to your needs!
10
 */
11 View Code Duplication
class Version20170516084212 extends AbstractMigration
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
12
{
13
    /**
14
     * @param Schema $schema
15
     * @return void
16
     */
17
    public function up(Schema $schema)
18
    {
19
        $this->abortIf(
20
            $this->connection->getDatabasePlatform()->getName() != 'mysql',
21
            'Migration can only be executed safely on \'mysql\'.'
22
        );
23
24
        $this->addSql('
25
            CREATE TABLE page_blocks(
26
                id INT AUTO_INCREMENT NOT null,
27
                page_group_id INT NOT null,
28
                title VARCHAR(255) NOT null,
29
                html LONGTEXT NOT null,
30
                position INT DEFAULT null,
31
                updated_at DATETIME NOT null,
32
                active TINYINT(1) NOT null,
33
            PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
34
        ');
35
36
        $this->addSql('
37
            CREATE TABLE page_groups(
38
                id INT AUTO_INCREMENT NOT null,
39
                slug VARCHAR(80) NOT null UNIQUE ,
40
                meta_keywords VARCHAR(255) NOT null,
41
                meta_description VARCHAR(255) DEFAULT null,
42
                meta_social LONGTEXT DEFAULT null,
43
                updated_at DATETIME NOT null,
44
                active TINYINT(1) NOT null,
45
            PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
46
        ');
47
48
        $this->addSql('ALTER TABLE page_blocks ADD FOREIGN KEY  (page_group_id) REFERENCES page_groups(id);');
49
    }
50
51
    /**
52
     * @param Schema $schema
53
     * @return void
54
     */
55
    public function down(Schema $schema)
56
    {
57
        // this down() migration is auto-generated, please modify it to your needs
58
    }
59
}
60