Total Complexity | 2 |
Total Lines | 22 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
7 | class AddRelationsTable extends Migration |
||
8 | { |
||
9 | public function up() |
||
10 | { |
||
11 | Schema::create('relations', function (Blueprint $table) { |
||
12 | $table->string("parent_type"); |
||
13 | $table->unsignedBigInteger("parent_id"); |
||
14 | $table->string("child_type"); |
||
15 | $table->unsignedBigInteger("child_id"); |
||
16 | |||
17 | $table->tinyInteger('sort')->default(0); |
||
18 | |||
19 | $table->index(["parent_type", "parent_id"], 'parent_index'); |
||
20 | $table->index(["child_type", "child_id"], 'child_index'); |
||
21 | |||
22 | $table->primary(["parent_type", "parent_id", "child_type", "child_id"]); |
||
23 | }); |
||
24 | } |
||
25 | |||
26 | public function down() |
||
27 | { |
||
28 | Schema::dropIfExists('relations'); |
||
29 | } |
||
31 |