CreateUserSocialTable   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 44
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 22 1
A down() 0 8 2
1
<?php
2
3
use Illuminate\Database\Migrations\Migration;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Support\Facades\DB;
6
7
class CreateUserSocialTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::create('user_socials', function (Blueprint $table) {
17
            $table->increments('id');
18
            $table->integer('user_id')->unsigned();
19
            $table->string('provider');
20
            $table->string('social_id')->index();
21
            $table->string('email')->index()->nullable();
22
            $table->string('avatar')->nullable();
23
            $table->string('token');
24
            $table->string('refresh_token')->nullable();
25
            $table->integer('expires_in')->nullable();
26
            $table->timestamps();
27
28
            $table->foreign('user_id')
29
                  ->references('id')
30
                  ->on('users')
31
                  ->onDelete('cascade');
32
        });
33
34
        DB::statement('ALTER TABLE `users` MODIFY `password` VARCHAR(64);');
35
    }
36
37
    /**
38
     * Reverse the migrations.
39
     *
40
     * @return void
41
     */
42
    public function down()
43
    {
44
        Schema::drop('user_socials');
45
46
        if (DB::table('users')->count() === 0) {
47
            DB::statement('ALTER TABLE `users` MODIFY `password` VARCHAR(64) NOT NULL;');
48
        }
49
    }
50
}
51