m180507_120119_create_gallery_lang_table.php
1.26 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
<?php
use yii\db\Migration;
/**
* Handles the creation of table `gallery_lang`.
*/
class m180507_120119_create_gallery_lang_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->createTable('gallery_lang', [
'gallery_id' => $this->integer()
->notNull(),
'language_id' => $this->integer()
->notNull(),
'title' => $this->string(),
'PRIMARY KEY(gallery_id, language_id)',
]);
$this->addForeignKey(
'gallery_lang_fk',
'gallery_lang',
'language_id',
'language',
'id',
'RESTRICT',
'CASCADE'
);
$this->addForeignKey(
'gallery_fk',
'gallery_lang',
'gallery_id',
'gallery',
'id',
'CASCADE',
'CASCADE'
);
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropForeignKey('gallery_lang_fk', 'gallery_lang');
$this->dropForeignKey('gallery_fk', 'gallery_lang');
$this->dropTable('gallery_lang');
}
}