Passed
Push — master ( f762ef...190e8a )
by Julito
09:11
created

Version20150505142900::down()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/* For licensing terms, see /license.txt */
3
4
namespace Chamilo\CoreBundle\Migrations\Schema\V110;
5
6
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
7
use Doctrine\DBAL\Schema\Schema;
8
use Doctrine\DBAL\Types\Type;
9
10
/**
11
 * Class Version20150505142900
12
 *
13
 * @package Chamilo\CoreBundle\Migrations\Schema\V110
14
 */
15
class Version20150505142900 extends AbstractMigrationChamilo
16
{
17
    /**
18
     * @param Schema $schema
19
     *
20
     * @throws \Doctrine\DBAL\Schema\SchemaException
21
     */
22
    public function up(Schema $schema)
23
    {
24
        // Create table for video chat
25
        if (!$schema->hasTable('chat_video')) {
26
            $chatVideoTable = $schema->createTable('chat_video');
27
            $chatVideoTable->addColumn(
28
                'id',
29
                Type::INTEGER,
30
                ['autoincrement' => true, 'notnull' => true]
31
            );
32
            $chatVideoTable->addColumn(
33
                'from_user',
34
                Type::INTEGER,
35
                ['notnull' => true]
36
            );
37
            $chatVideoTable->addColumn(
38
                'to_user',
39
                Type::INTEGER,
40
                ['notnull' => true]
41
            );
42
            $chatVideoTable->addColumn(
43
                'room_name',
44
                Type::STRING,
45
                ['length' => 255, 'notnull' => true]
46
            );
47
            $chatVideoTable->addColumn(
48
                'datetime',
49
                Type::DATETIME,
50
                ['notnull' => true]
51
            );
52
            $chatVideoTable->setPrimaryKey(['id']);
53
            $chatVideoTable->addIndex(
54
                ['from_user'],
55
                'idx_chat_video_from_user'
56
            );
57
            $chatVideoTable->addIndex(['to_user'], 'idx_chat_video_to_user');
58
            $chatVideoTable->addIndex(
59
                ['from_user', 'to_user'],
60
                'idx_chat_video_users'
61
            );
62
            $chatVideoTable->addIndex(
63
                ['room_name'],
64
                'idx_chat_video_room_name'
65
            );
66
        }
67
    }
68
69
    /**
70
     * We don't allow downgrades yet
71
     * @param Schema $schema
72
     */
73
    public function down(Schema $schema)
74
    {
75
        $schema->dropTable('chat_video');
76
    }
77
}
78