m160208_095412_portfolio.php
1.57 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
<?php
use yii\db\Migration;
class m160208_095412_portfolio extends Migration
{
public function up()
{
$tableOptions = null;
$this->createTable('{{%portfolio}}', [
'portfolio_id' => $this->primaryKey(),
'user_id' => $this->integer()->notNull(),
'name' => $this->string(255)->notNull(),
'link' => $this->string(255),
'date_add' => $this->timestamp()->notNull(),
'user_add_id' => $this->integer(),
'view_count' => $this->integer()->defaultValue(0),
'city' => $this->string(255),
'street' => $this->string(255),
'house' => $this->string(255),
'description' => $this->text(),
'cover' => $this->text(),
'gallery_id' => $this->integer(),
], $tableOptions);
$this->createTable (
'{{%portfolio_specialization}}', [
'portfolio_specialization_id' => $this->primaryKey (), 'portfolio_id' => $this->integer (), 'specialization_id' => $this->integer (),
]
);
$this->addForeignKey ('portfolio_specialization_index', '{{%portfolio_specialization}}', 'specialization_id', '{{%specialization}}', 'specialization_id', 'CASCADE', 'CASCADE');
$this->addForeignKey ('specialization_portfolio_index', '{{%portfolio_specialization}}', 'portfolio_id', '{{%portfolio}}', 'portfolio_id', 'CASCADE', 'CASCADE');
}
public function down()
{
$this->dropTable('{{%portfolio_specialization}}');
$this->dropTable('{{%portfolio}}');
}
}