| Total Complexity | 2 |
| Total Lines | 45 |
| Duplicated Lines | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 18 | final class CreateLoveReactantReactionCountersTable extends Migration |
||
| 19 | { |
||
| 20 | /** |
||
| 21 | * Run the migrations. |
||
| 22 | * |
||
| 23 | * @return void |
||
| 24 | */ |
||
| 25 | public function up(): void |
||
| 26 | { |
||
| 27 | Schema::create('love_reactant_reaction_counters', function (Blueprint $table) { |
||
| 28 | $table->bigIncrements('id'); |
||
| 29 | $table->unsignedBigInteger('reactant_id'); |
||
| 30 | $table->unsignedBigInteger('reaction_type_id'); |
||
| 31 | $table->unsignedBigInteger('count')->default(0); |
||
| 32 | $table->bigInteger('weight')->default(0); |
||
| 33 | $table->timestamps(); |
||
| 34 | |||
| 35 | $table->index('reactant_id'); |
||
| 36 | $table->index('reaction_type_id'); |
||
| 37 | $table->index([ |
||
| 38 | 'reactant_id', |
||
| 39 | 'reaction_type_id', |
||
| 40 | ], 'love_reactant_reaction_counters_reactant_reaction_type_index'); |
||
| 41 | |||
| 42 | $table |
||
| 43 | ->foreign('reactant_id') |
||
| 44 | ->references('id') |
||
| 45 | ->on('love_reactants') |
||
| 46 | ->onDelete('cascade'); |
||
| 47 | $table |
||
| 48 | ->foreign('reaction_type_id') |
||
| 49 | ->references('id') |
||
| 50 | ->on('love_reaction_types') |
||
| 51 | ->onDelete('cascade'); |
||
| 52 | }); |
||
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Reverse the migrations. |
||
| 57 | * |
||
| 58 | * @return void |
||
| 59 | */ |
||
| 60 | public function down(): void |
||
| 63 | } |
||
| 64 | } |
||
| 65 |