m180622_143240_social_auth_create_social_user_services.php 1.81 KB
Newer Older
Marcello Pivanti's avatar
Marcello Pivanti committed
1
2
3
4
5
6
7
<?php

/**
 * Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
 * OPEN 2.0
 *
 *
waltermazza's avatar
waltermazza committed
8
 * @package    arter\amos\socialauth\migrations
Marcello Pivanti's avatar
Marcello Pivanti committed
9
10
11
12
 * @category   CategoryName
 * @author     Elite Division S.r.l.
 */

waltermazza's avatar
waltermazza committed
13
use arter\amos\core\migration\AmosMigrationTableCreation;
Marcello Pivanti's avatar
Marcello Pivanti committed
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

/**
 * Class m180622_143240_social_auth_create_social_user_services
 */
class m180622_143240_social_auth_create_social_user_services extends AmosMigrationTableCreation
{
    /**
     * @inheritdoc
     */
    protected function setTableName()
    {
        $this->tableName = '{{%social_user_services}}';
    }

    /**
     * @inheritdoc
     */
    protected function setTableFields()
    {
        $this->tableFields = [
            'id' => $this->primaryKey(),
            'social_users_id' => $this->integer(11)->notNull()->comment('Social User Id'),
            'service' => $this->string(255)->notNull()->comment('Service name'),
            'access_token' => $this->string(255)->null()->comment('Service Access Token'),
            'token_type' => $this->string(255)->null()->comment('Token type'),
            'expires_in' => $this->integer(11)->null()->comment('Access token expiration'),
            'refresh_token' => $this->string(255)->null()->comment('Refresh token'),
            'token_created' => $this->integer(11)->null()->comment('created_at'),
            'service_id' =>  $this->string(255)->null()->comment('Service ID'),
        ];
    }

    /**
     * @inheritdoc
     */
    protected function beforeTableCreation()
    {
        parent::beforeTableCreation();
        $this->setAddCreatedUpdatedFields(true);
    }

    /**
     * @inheritdoc
     */
    protected function addForeignKeys()
    {
        $this->addForeignKey('fk_social_user_services_social_users', $this->getRawTableName(), 'social_users_id', '{{%social_users}}', 'id');
    }
}