Schema   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 63
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createQueryBuilder() 0 6 2
A createColumnSchemaBuilder() 0 4 1
1
<?php
2
3
/**
4
 *  _   __ __ _____ _____ ___  ____  _____
5
 * | | / // // ___//_  _//   ||  __||_   _|
6
 * | |/ // /(__  )  / / / /| || |     | |
7
 * |___//_//____/  /_/ /_/ |_||_|     |_|
8
 * @link https://vistart.me/
9
 * @copyright Copyright (c) 2016 - 2017 vistart
10
 * @license https://vistart.me/license/
11
 */
12
13
namespace rhosocial\user\migrations\mysql;
14
15
/**
16
 * @version 1.0
17
 * @author vistart <[email protected]>
18
 */
19
class Schema extends \yii\db\mysql\Schema
20
{
21
    const TYPE_BLOB = 'blob';
22
    const TYPE_BINARY_PK = 'binary_pk';
23
    const TYPE_GUID_PK = 'binary_pk';
24
    const TYPE_TINYINT = 'tinyint';
25
    const TYPE_VARCHAR = 'varchar';
26
    const TYPE_VARBINARY = 'varbinary';
27
    
28
    /**
29
     * @var array mapping from physical column types (keys) to abstract column types (values)
30
     */
31
    public $typeMap = [
32
        'tinyint' => self::TYPE_TINYINT,
33
        'bit' => self::TYPE_INTEGER,
34
        'smallint' => self::TYPE_SMALLINT,
35
        'mediumint' => self::TYPE_INTEGER,
36
        'int' => self::TYPE_INTEGER,
37
        'integer' => self::TYPE_INTEGER,
38
        'bigint' => self::TYPE_BIGINT,
39
        'float' => self::TYPE_FLOAT,
40
        'double' => self::TYPE_DOUBLE,
41
        'real' => self::TYPE_FLOAT,
42
        'decimal' => self::TYPE_DECIMAL,
43
        'numeric' => self::TYPE_DECIMAL,
44
        'tinytext' => self::TYPE_TEXT,
45
        'mediumtext' => self::TYPE_TEXT,
46
        'longtext' => self::TYPE_TEXT,
47
        'longblob' => self::TYPE_BLOB,
48
        'blob' => self::TYPE_BLOB,
49
        'text' => self::TYPE_TEXT,
50
        'string' => self::TYPE_STRING,
51
        'char' => self::TYPE_CHAR,
52
        'varchar' => self::TYPE_VARCHAR,
53
        'datetime' => self::TYPE_DATETIME,
54
        'year' => self::TYPE_DATE,
55
        'date' => self::TYPE_DATE,
56
        'time' => self::TYPE_TIME,
57
        'timestamp' => self::TYPE_TIMESTAMP,
58
        'enum' => self::TYPE_STRING,
59
        'binary' => self::TYPE_BINARY,
60
        'varbinary' => self::TYPE_VARBINARY,
61
    ];
62
63
    /**
64
     * Creates a query builder for the MySQL database.
65
     * @return QueryBuilder query builder instance
66
     */
67
    public function createQueryBuilder()
68
    {
69
        if ($this->db->driverName == 'mysql') {
70
            return new QueryBuilder($this->db);
71
        }
72
    }
73
74
    /**
75
     * @inheritdoc
76
     */
77
    public function createColumnSchemaBuilder($type, $length = null)
78
    {
79
        return new ColumnSchemaBuilder($type, $length, $this->db);
80
    }
81
}