|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the 2amigos/yii2-usuario project. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) 2amigOS! <http://2amigos.us/> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view |
|
9
|
|
|
* the LICENSE file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Da\User\Migration; |
|
13
|
|
|
|
|
14
|
|
|
use Da\User\Helper\MigrationHelper; |
|
15
|
|
|
use yii\db\Migration; |
|
16
|
|
|
|
|
17
|
|
|
class m000000_000002_create_profile_table extends Migration |
|
18
|
|
|
{ |
|
19
|
|
|
public function safeUp() |
|
20
|
|
|
{ |
|
21
|
|
|
$this->createTable( |
|
22
|
|
|
'{{%profile}}', |
|
23
|
|
|
[ |
|
24
|
|
|
'user_id' => $this->integer()->notNull(), |
|
25
|
|
|
'name' => $this->string(255), |
|
26
|
|
|
'public_email' => $this->string(255), |
|
27
|
|
|
'gravatar_email' => $this->string(255), |
|
28
|
|
|
'gravatar_id' => $this->string(32), |
|
29
|
|
|
'location' => $this->string(255), |
|
30
|
|
|
'website' => $this->string(255), |
|
31
|
|
|
'timezone' => $this->string(40), |
|
32
|
|
|
'bio' => $this->text(), |
|
33
|
|
|
], |
|
34
|
|
|
MigrationHelper::resolveTableOptions($this->db->driverName) |
|
35
|
|
|
); |
|
36
|
|
|
|
|
37
|
|
|
$this->addPrimaryKey('{{%profile_pk}}', '{{%profile}}', 'user_id'); |
|
38
|
|
|
|
|
39
|
|
|
$restrict = MigrationHelper::isMicrosoftSQLServer($this->db->driverName) ? 'NO ACTION' : 'RESTRICT'; |
|
40
|
|
|
|
|
41
|
|
|
$this->addForeignKey('fk_profile_user', '{{%profile}}', 'user_id', '{{%user}}', 'id', 'CASCADE', $restrict); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function safeDown() |
|
45
|
|
|
{ |
|
46
|
|
|
$this->dropTable('{{%profile}}'); |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
|