m160217_092739_currency_table.php
1.79 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
use yii\db\Migration;
class m160217_092739_currency_table extends Migration
{
public function up()
{
$this->createTable('{{%currency}}', [
'currency_id' => $this->primaryKey(),
'name' => $this->string(),
'symbol' => $this->string(),
'code' => $this->string(3),
'rate' => $this->float(4),
'date_update' => $this->timestamp()->defaultExpression('NOW()')
->notNull(),
'is_default' => $this->smallInteger(),
]);
$this->batchInsert('{{%currency}}', [
'currency_id',
'name',
'symbol',
'code',
'rate',
'is_default',
], [
[
1,
'Доллар США',
'$',
'USD',
27.31,
0,
],
[
2,
'Евро',
'€',
'EUR',
30.28,
0
],
[
3,
'Украинская гривна',
'₴',
'UAH',
1,
1,
],
[
4,
'Российский рубль',
'₽',
'RUB',
0.34,
0,
],
]);
}
public function down()
{
$this->dropTable('{{%currency}}');
}
}