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

Version20150529164400::up()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 40
Code Lines 30

Duplication

Lines 40
Ratio 100 %

Importance

Changes 0
Metric Value
cc 2
eloc 30
nc 2
nop 1
dl 40
loc 40
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 Version20150529164400 extends AbstractMigrationChamilo
14
{
15
    /**
16
     * @param Schema $schema
17
     */
18
    public function up(Schema $schema)
19
    {
20
        if (!$schema->hasTable('gradebook_score_log')) {
21
            $gradebookScoreLog = $schema->createTable('gradebook_score_log');
22
            $gradebookScoreLog->addColumn(
23
                'id',
24
                TableColumnType::INTEGER,
25
                ['unsigned' => true, 'autoincrement' => true, 'notnull' => true]
26
            );
27
            $gradebookScoreLog->addColumn(
28
                'category_id',
29
                TableColumnType::INTEGER,
30
                ['unsigned' => true, 'notnull' => true]
31
            );
32
            $gradebookScoreLog->addColumn(
33
                'user_id',
34
                TableColumnType::INTEGER,
35
                ['unsigned' => true, 'notnull' => true]
36
            );
37
            $gradebookScoreLog->addColumn(
38
                'score',
39
                TableColumnType::FLOAT,
40
                ['notnull' => true, 'scale' => 0, 'precision' => 10]
41
            );
42
            $gradebookScoreLog->addColumn(
43
                'registered_at',
44
                TableColumnType::DATETIME,
45
                ['notnull' => true]
46
            );
47
            $gradebookScoreLog->setPrimaryKey(['id']);
48
            $gradebookScoreLog->addIndex(
49
                ['user_id'],
50
                'idx_gradebook_score_log_user'
51
            );
52
            $gradebookScoreLog->addIndex(
53
                ['user_id', 'category_id'],
54
                'idx_gradebook_score_log_user_category'
55
            );
56
        }
57
    }
58
59
    /**
60
     * @param Schema $schema
61
     */
62
    public function down(Schema $schema)
63
    {
64
        $schema->dropTable('gradebook_score_log');
65
    }
66
67
}
68