CreateQuickBooksTokensTable   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 17
c 2
b 0
f 0
dl 0
loc 38
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A down() 0 3 1
A up() 0 20 2
1
<?php
2
3
use Illuminate\Database\Migrations\Migration;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Support\Facades\DB;
6
use Illuminate\Support\Facades\Schema;
7
8
class CreateQuickBooksTokensTable extends Migration
9
{
10
    /**
11
     * Run the migrations.
12
     *
13
     * @return void
14
     */
15
    public function up()
16
    {
17
        Schema::create('quickbooks_tokens', function (Blueprint $table) {
18
            $user_id_type = DB::getSchemaBuilder()
19
                              ->getColumnType('users', 'id') === 'bigint' ? 'unsignedBigInteger' : 'unsignedInteger';
20
21
            $table->bigIncrements('id');
22
            $table->{$user_id_type}('user_id');
23
            $table->unsignedBigInteger('realm_id');
24
            $table->longtext('access_token');
25
            $table->datetime('access_token_expires_at');
26
            $table->string('refresh_token');
27
            $table->datetime('refresh_token_expires_at');
28
29
            $table->timestamps();
30
31
            $table->foreign('user_id')
32
                  ->references('id')
33
                  ->on('users')
34
                  ->onDelete('cascade');
35
        });
36
    }
37
38
    /**
39
     * Reverse the migrations.
40
     *
41
     * @return void
42
     */
43
    public function down()
44
    {
45
        Schema::dropIfExists('quickbooks_tokens');
46
    }
47
}
48