CreateProfilesTable   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 35
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 17 2
A down() 0 3 1
1
<?php
2
3
use Illuminate\Support\Facades\Schema;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Database\Migrations\Migration;
6
7
class CreateProfilesTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        if (Schema::hasTable('profiles')) return;
17
        
18
        Schema::create('profiles', function (Blueprint $table) {
19
            $table->increments('id');
20
            $table->integer('user_id')->unsigned()->index();
21
            $table->string('age', 3)->nullable();
22
            $table->string('location', 35)->nullable();
23
            $table->text('bio')->nullable();
24
            $table->timestamps();
25
26
            $table->foreign('user_id')
27
                  ->references('id')
28
                  ->on('users')
29
                  ->onDelete('cascade')
30
                  ->onUpdate('cascade');
31
        });
32
    }
33
34
    /**
35
     * Reverse the migrations.
36
     *
37
     * @return void
38
     */
39
    public function down()
40
    {
41
        Schema::dropIfExists('profiles');
42
    }
43
}
44