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

Version20150505142900   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 63
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 3
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;
9
10
/**
11
 * Class Version20150505142900
12
 *
13
 * @package Application\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