for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of Laravel Love.
*
* (c) Anton Komarev <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
use Cog\Laravel\Love\Reactant\Models\Reactant;
use Cog\Laravel\Love\Reacter\Models\Reacter;
use Cog\Laravel\Love\Reaction\Models\Reaction;
use Cog\Laravel\Love\ReactionType\Models\ReactionType;
use Cog\Laravel\Love\Support\Database\Migration;
use Illuminate\Database\Schema\Blueprint;
return new class extends Migration
{
/**
* Run the migrations.
public function up(): void
$this->schema->create((new Reaction())->getTable(), function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('reactant_id');
$table->unsignedBigInteger('reacter_id');
$table->unsignedBigInteger('reaction_type_id');
$table->decimal('rate', 4, 2);
$table->timestamps();
$table->index([
'reactant_id',
'reaction_type_id',
]);
'reacter_id',
$table
->foreign('reactant_id')
->references('id')
->on((new Reactant())->getTable())
->onDelete('cascade');
->foreign('reacter_id')
->on((new Reacter())->getTable())
->foreign('reaction_type_id')
->on((new ReactionType())->getTable())
});
}
* Reverse the migrations.
public function down(): void
$this->schema->dropIfExists((new Reaction())->getTable());
};