aboutsummaryrefslogtreecommitdiff
path: root/db/migrations/5.4.5_create_cw_clipboards_table.php
blob: 02fc9613a9d1146e3af8c3b3b9a1a40f90c9fce5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php

class CreateCwClipboardsTable extends Migration
{
    public function description()
    {
        return 'create table for courseware clipboards';
    }

    public function up()
    {
        $db = DBManager::get();

        $query = "CREATE TABLE IF NOT EXISTS `cw_clipboards` (
            `id`                    INT(11) NOT NULL AUTO_INCREMENT,
            `user_id`               CHAR(32) COLLATE latin1_bin NOT NULL,
            `name`                  VARCHAR(255) NOT NULL,
            `description`           MEDIUMTEXT NOT NULL,
            `block_id`              INT(11) NULL,
            `container_id`          INT(11) NULL,
            `structural_element_id` INT(11) NULL,
            `object_type`           ENUM('courseware-structural-elements', 'courseware-containers', 'courseware-blocks') COLLATE latin1_bin NOT NULL,
            `object_kind`           VARCHAR(255) COLLATE latin1_bin NOT NULL,
            `backup`                MEDIUMTEXT NOT NULL,
            `mkdate`                INT(11) UNSIGNED NOT NULL,
            `chdate`                INT(11) UNSIGNED NOT NULL,

            PRIMARY KEY (`id`),
            INDEX index_user_id (`user_id`)
        )";
        $db->exec($query);
    }

    public function down()
    {
        $db = \DBManager::get();
        $db->exec('DROP TABLE IF EXISTS `cw_clipboards`');
    }
}