database/migrations/2015_03_16_030116_create_votes_table.php
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateVotesTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('votes', function (Blueprint $table) {
$table->boolean('up');
// Relations
$table->integer('element_id')->unsigned();
$table->string('element_type');
$table->integer('user_id')->unsigned();
$table->foreign('user_id')->references('id')->on('users');
$table->timestamp('created_at');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::drop('votes');
}
}