| Total Complexity | 2 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class CreateRelatedTable extends Migration |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * Run the migrations. |
||
| 11 | * |
||
| 12 | * @return void |
||
| 13 | */ |
||
| 14 | public function up() |
||
| 15 | { |
||
| 16 | Schema::create('related', function (Blueprint $table) { |
||
| 17 | $table->integer('subject_id')->nullable()->unsigned(); |
||
| 18 | $table->string('subject_type', 255); |
||
| 19 | $table->integer('related_id')->nullable()->unsigned(); |
||
| 20 | $table->string('related_type', 255); |
||
| 21 | $table->string('browser_name')->index(); |
||
| 22 | $table->integer('position')->unsigned(); |
||
| 23 | |||
| 24 | $table->unique( |
||
| 25 | ['subject_id', 'subject_type', 'related_id', 'related_type', 'browser_name'], |
||
| 26 | 'related_unique' |
||
| 27 | ); |
||
| 28 | }); |
||
| 29 | } |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Reverse the migrations. |
||
| 33 | * |
||
| 34 | * @return void |
||
| 35 | */ |
||
| 36 | public function down() |
||
| 37 | { |
||
| 38 | Schema::dropIfExists('related'); |
||
| 39 | } |
||
| 41 |