1 | <?php |
||
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 |