database/migrations/2015_03_15_000004_create_comments_table.php
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCommentsTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('comments', function (Blueprint $table) {
$table->increments('id');
$table->text('text');
$table->text('text_source');
// Relations
$table->integer('user_id')->unsigned();
$table->foreign('user_id')->references('id')->on('users');
$table->integer('group_id')->unsigned();
$table->foreign('group_id')->references('id')->on('groups');
$table->integer('content_id')->unsigned();
$table->foreign('content_id')->references('id')->on('contents');
// Vote counts
$table->integer('uv')->unsigned()->default(0);
$table->integer('dv')->unsigned()->default(0);
$table->integer('score')->default(0);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::drop('comments');
}
}