mirror of
https://github.com/m1ngsama/php.git
synced 2025-12-24 07:56:01 +00:00
Created migrations for communities, posts, comments, votes, and user karma tracking.
26 lines
670 B
PHP
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');
|
|
}
|
|
};
|