Version20140415172522_AddItemLabel::up()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 18
rs 9.4285
cc 1
eloc 6
nc 1
nop 1
1
<?php
2
/**
3
 * AnimeDb package.
4
 *
5
 * @author    Peter Gribanov <[email protected]>
6
 * @copyright Copyright (c) 2011, Peter Gribanov
7
 * @license   http://opensource.org/licenses/GPL-3.0 GPL v3
8
 */
9
10
namespace AnimeDb\Bundle\CatalogBundle\DoctrineMigrations;
11
12
use Doctrine\DBAL\Migrations\AbstractMigration;
13
use Doctrine\DBAL\Schema\Schema;
14
15
/**
16
 * Auto-generated Migration: Please modify to your needs!
17
 */
18
class Version20140415172522_AddItemLabel extends AbstractMigration
19
{
20
    /**
21
     * @param Schema $schema
22
     */
23
    public function up(Schema $schema)
24
    {
25
        $this->addSql('CREATE TABLE label (
26
            id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
27
            name VARCHAR(16) NOT NULL
28
        )');
29
        // add index
30
        $this->addSql('CREATE INDEX label_name_idx ON label (name)');
31
32
        $this->addSql('CREATE TABLE items_labels (
33
            item_id INTEGER NOT NULL,
34
            label_id INTEGER NOT NULL,
35
            PRIMARY KEY(item_id, label_id)
36
        )');
37
        // add index
38
        $this->addSql('CREATE INDEX item_labels_item_id_idx ON items_labels (item_id)');
39
        $this->addSql('CREATE INDEX item_labels_label_id_idx ON items_labels (label_id)');
40
    }
41
42
    /**
43
     * @param Schema $schema
44
     */
45
    public function down(Schema $schema)
46
    {
47
        $schema->dropTable('label');
48
        $schema->dropTable('items_labels');
49
    }
50
}
51