Total Complexity | 7 |
Total Lines | 39 |
Duplicated Lines | 0 % |
Coverage | 85.71% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
16 | class m160313_153426_session_init extends Migration |
||
17 | { |
||
18 | /** |
||
19 | * {@inheritdoc} |
||
20 | */ |
||
21 | 30 | public function up() |
|
22 | { |
||
23 | 30 | $dataType = $this->binary(); |
|
24 | 30 | $tableOptions = null; |
|
25 | |||
26 | 30 | switch ($this->db->driverName) { |
|
27 | 30 | case 'mysql': |
|
28 | // https://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci |
||
29 | 10 | $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'; |
|
30 | 10 | break; |
|
31 | 20 | case 'sqlsrv': |
|
32 | 20 | case 'mssql': |
|
33 | 20 | case 'dblib': |
|
34 | // "varbinary(max)" added in SQL Server 2012 (version 11.0.0) |
||
35 | if (version_compare($this->getDb()->getServerVersion(), '11.0.0') < 0) { |
||
36 | $dataType = $this->text(); |
||
37 | } |
||
38 | break; |
||
39 | } |
||
40 | |||
41 | 30 | $this->createTable('{{%session}}', [ |
|
42 | 30 | 'id' => $this->string()->notNull(), |
|
43 | 30 | 'expire' => $this->integer(), |
|
44 | 30 | 'data' => $dataType, |
|
45 | 30 | 'PRIMARY KEY ([[id]])', |
|
46 | ], $tableOptions); |
||
47 | 30 | } |
|
48 | |||
49 | /** |
||
50 | * {@inheritdoc} |
||
51 | */ |
||
52 | 30 | public function down() |
|
55 | 30 | } |
|
56 | } |
||
57 |