m170524_123150_create_report_table.php 1.55 KB
Newer Older
Marcello Pivanti's avatar
Marcello Pivanti committed
1
2
3
4
5
6
7
<?php

/**
 * Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
 * OPEN 2.0
 *
 *
waltermazza's avatar
waltermazza committed
8
 * @package    arter\amos\report\migrations
Marcello Pivanti's avatar
Marcello Pivanti committed
9
10
11
12
 * @category   Migration
 * @author     Elite Division S.r.l.
 */

waltermazza's avatar
waltermazza committed
13
use arter\amos\core\migration\AmosMigrationTableCreation;
Marcello Pivanti's avatar
Marcello Pivanti committed
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53

/**
 * Handles the creation of table `report`.
 */
class m170524_123150_create_report_table extends AmosMigrationTableCreation
{
    /**
     * @inheritdoc
     */
    protected function setTableName()
    {
        $this->tableName = '{{%report}}';
    }

    /**
     * @inheritdoc
     */
    protected function setTableFields()
    {
        $this->tableFields = [
            'id' => $this->primaryKey(),
            'context_id' => $this->integer()->notNull()->comment('Report Context ID'),
            'classname' => $this->text()->notNull()->comment('Foreign class name'),
            'type' => $this->integer()->notNull()->comment('Report Type ID'),
            'content' => $this->text()->notNull()->comment('Report content'),
            'status' =>  $this->integer()->notNull()->defaultValue(0)->comment('Report Status ( 0 unread, 1 read )'),
            'creator_id' => $this->integer()->notNull()->comment('Creator User ID'),
            'read_at' => $this->dateTime()->null()->defaultValue(null)->comment('Report read at'),
            'read_by' => $this->integer()->notNull()->comment('Read User ID'),
        ];
    }
    /**
     * @inheritdoc
     */
    protected function beforeTableCreation()
    {
        parent::beforeTableCreation();
        $this->setAddCreatedUpdatedFields(true);
    }
}