php/database/migrations/2024_01_01_000007_create_votes_table.php
m1ngsama 34f73d3207 Add database migrations for forum functionality
Created migrations for communities, posts, comments, votes, and user karma tracking.
2025-11-24 10:30:00 +08:00

26 lines
670 B
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('votes', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->onDelete('cascade');
$table->morphs('voteable');
$table->tinyInteger('vote');
$table->timestamps();
$table->unique(['user_id', 'voteable_id', 'voteable_type']);
});
}
public function down(): void
{
Schema::dropIfExists('votes');
}
};