safeUp()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 10
nc 2
nop 0
1
<?php
2
/**
3
 * @link https://github.com/yiimaker/yii2-newsletter
4
 * @copyright Copyright (c) 2017 Yii Maker
5
 * @license BSD 3-Clause License
6
 */
7
8
use yii\db\Migration;
9
10
/**
11
 * Handles the creation of table `newsletter_client`.
12
 *
13
 * @author Vladimir Kuprienko <[email protected]>
14
 * @since 1.0
15
 */
16
class m170619_133956_create_newsletter_client_table extends Migration
17
{
18
    /**
19
     * @var string Migration tabel name.
20
     */
21
    public $tableName = '{{%newsletter_client}}';
22
23
24
    /**
25
     * @inheritdoc
26
     */
27
    public function safeUp()
28
    {
29
        $tableOptions = null;
30
        if ($this->db->driverName === 'mysql') {
31
            /* @link http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci */
32
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
33
        }
34
35
        $this->createTable(
36
            $this->tableName,
37
            [
38
                'id'            => $this->primaryKey()->comment('ID'),
39
                'contacts'      => $this->string(255)->comment('Contacts'),
40
                'created_at'    => $this->integer()->notNull()->comment('Created at'),
41
                'updated_at'    => $this->integer()->notNull()->comment('Updated at'),
42
            ],
43
            $tableOptions
44
        );
45
    }
46
47
    /**
48
     * @inheritdoc
49
     */
50
    public function safeDown()
51
    {
52
        $this->dropTable($this->tableName);
53
    }
54
}
55