|
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_000003_create_social_account_table extends Migration |
|
18
|
|
|
{ |
|
19
|
|
|
public function safeUp() |
|
20
|
|
|
{ |
|
21
|
|
|
$this->createTable( |
|
22
|
|
|
'{{%social_account}}', |
|
23
|
|
|
[ |
|
24
|
|
|
'id' => $this->primaryKey(), |
|
25
|
|
|
'user_id' => $this->integer(), |
|
26
|
|
|
'provider' => $this->string(255)->notNull(), |
|
27
|
|
|
'client_id' => $this->string(255)->notNull(), |
|
28
|
|
|
'code' => $this->string(32), |
|
29
|
|
|
'email' => $this->string(255), |
|
30
|
|
|
'username' => $this->string(255), |
|
31
|
|
|
'data' => $this->text(), |
|
32
|
|
|
'created_at' => $this->integer(), |
|
33
|
|
|
], |
|
34
|
|
|
MigrationHelper::resolveTableOptions($this->db->driverName) |
|
35
|
|
|
); |
|
36
|
|
|
|
|
37
|
|
|
$this->createIndex( |
|
38
|
|
|
'idx_social_account_provider_client_id', |
|
39
|
|
|
'{{%social_account}}', |
|
40
|
|
|
['provider', 'client_id'], |
|
41
|
|
|
true |
|
42
|
|
|
); |
|
43
|
|
|
|
|
44
|
|
|
$this->createIndex('idx_social_account_code', '{{%social_account}}', 'code', true); |
|
45
|
|
|
|
|
46
|
|
|
$this->addForeignKey( |
|
47
|
|
|
'fk_social_account_user', |
|
48
|
|
|
'{{%social_account}}', |
|
49
|
|
|
'user_id', |
|
50
|
|
|
'{{%user}}', |
|
51
|
|
|
'id', |
|
52
|
|
|
'CASCADE', |
|
53
|
|
|
(MigrationHelper::isMicrosoftSQLServer($this->db->driverName) ? 'NO ACTION' : 'RESTRICT') |
|
54
|
|
|
); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function safeDown() |
|
58
|
|
|
{ |
|
59
|
|
|
$this->dropTable('{{%social_account}}'); |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|