Completed
Push — master ( 7b0cec...95f4c8 )
by Alexandr
06:11
created

CreateLinkTable   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 36
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 2
1
<?php
2
3
use Illuminate\Database\Migrations\Migration;
4
use Illuminate\Database\Schema\Blueprint;
5
6
class CreateLinkTable extends Migration {
7
8
	/**
9
	 * Run the migrations.
10
	 *
11
	 * @return void
12
	 */
13
	public function up()
14
	{
15
        if( !Schema::hasTable('link')){
16
            Schema::create('link', function(Blueprint $table)
17
            {
18
                $table->increments('id');
19
                $table->integer('id_parent')->unsigned();
20
                $table->integer('id_child')->unsigned();
21
                $table->char('model_parent', 191);
22
                $table->char('model_child', 191);
23
                $table->float('cost')->nullable();
24
                $table->timestamps();
25
                $table->index(['id_parent', 'model_parent', 'model_child']);
26
            });
27
        }
28
	}
29
30
31
	/**
32
	 * Reverse the migrations.
33
	 *
34
	 * @return void
35
	 */
36
	public function down()
37
	{
38
		Schema::dropIfExists('link');
39
	}
40
41
}
42