Completed
Push — 1.10.x ( 2635b5...f0080b )
by Yannick
165:55 queued 120:08
created

Version20150608104600::up()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 43
Code Lines 32

Duplication

Lines 43
Ratio 100 %

Importance

Changes 0
Metric Value
cc 2
eloc 32
nc 2
nop 1
dl 43
loc 43
rs 8.8571
c 0
b 0
f 0
1
<?php
2
/* For licensing terms, see /license.txt */
3
4
namespace Application\Migrations\Schema\V110;
5
6
use Application\Migrations\AbstractMigrationChamilo;
7
use Doctrine\DBAL\Schema\Schema;
8
use Doctrine\DBAL\Types\Type as TableColumnType;
9
10
/**
11
 * Session date changes
12
 */
13
class Version20150608104600 extends AbstractMigrationChamilo
14
{
15
    /**
16
     * @param Schema $schema
17
     */
18
    public function up(Schema $schema)
19
    {
20
        if (!$schema->hasTable('extra_field_rel_tag')) {
21
            $extraFieldRelTag = $schema->createTable('extra_field_rel_tag');
22
            $extraFieldRelTag->addColumn(
23
                'id',
24
                TableColumnType::INTEGER,
25
                ['unsigned' => true, 'autoincrement' => true, 'notnull' => true]
26
            );
27
            $extraFieldRelTag->addColumn(
28
                'field_id',
29
                TableColumnType::INTEGER,
30
                ['unsigned' => true, 'notnull' => true]
31
            );
32
            $extraFieldRelTag->addColumn(
33
                'item_id',
34
                TableColumnType::INTEGER,
35
                ['unsigned' => true, 'notnull' => true]
36
            );
37
            $extraFieldRelTag->addColumn(
38
                'tag_id',
39
                TableColumnType::INTEGER,
40
                ['unsigned' => true, 'notnull' => true]
41
            );
42
            $extraFieldRelTag->setPrimaryKey(['id']);
43
            $extraFieldRelTag->addIndex(
44
                ['field_id'],
45
                'idx_frt_field'
46
            );
47
            $extraFieldRelTag->addIndex(
48
                ['item_id'],
49
                'idx_frt_item'
50
            );
51
            $extraFieldRelTag->addIndex(
52
                ['tag_id'],
53
                'idx_frt_tag'
54
            );
55
            $extraFieldRelTag->addIndex(
56
                ['field_id', 'item_id', 'tag_id'],
57
                'idx_frt_field_item_tag'
58
            );
59
        }
60
    }
61
62
    /**
63
     * @param Schema $schema
64
     */
65
    public function down(Schema $schema)
66
    {
67
        $schema->dropTable('extra_field_rel_tag');
68
    }
69
70
}
71