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.
31 lines
973 B
PHP
31 lines
973 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('posts', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->foreignId('community_id')->constrained()->onDelete('cascade');
|
|
$table->foreignId('user_id')->constrained()->onDelete('cascade');
|
|
$table->string('title');
|
|
$table->text('content')->nullable();
|
|
$table->string('url')->nullable();
|
|
$table->enum('type', ['text', 'link', 'image'])->default('text');
|
|
$table->integer('votes')->default(0);
|
|
$table->timestamps();
|
|
|
|
$table->index(['community_id', 'created_at']);
|
|
$table->index(['user_id', 'created_at']);
|
|
});
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('posts');
|
|
}
|
|
};
|