Completed
Branch 2.0 (238d23)
by Zhengchao
02:57 queued 02:05
created

CreateReferralsTable   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 25
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 11 1
A down() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of questocat/laravel-referral package.
5
 *
6
 * (c) questocat <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
use Illuminate\Database\Migrations\Migration;
13
use Illuminate\Database\Schema\Blueprint;
14
use Illuminate\Support\Facades\Schema;
15
16
class CreateReferralsTable extends Migration
17
{
18
    /**
19
     * Run the migrations.
20
     */
21
    public function up()
22
    {
23
        Schema::create('referrals', function (Blueprint $table) {
24
            $table->increments('id');
25
            $table->integer('referrer_id')->unsigned();
26
            $table->integer('referral_id')->unsigned();
27
            $table->foreign('referrer_id')->references('id')->on('users')->onDelete('cascade');
28
            $table->foreign('referral_id')->references('id')->on('users')->onDelete('cascade');
29
            $table->timestamps();
30
        });
31
    }
32
33
    /**
34
     * Reverse the migrations.
35
     */
36
    public function down()
37
    {
38
        Schema::dropIfExists('referrals');
39
    }
40
}
41