trypost/database/migrations/2026_01_14_232321_create_posts_table.php
2026-05-19 08:19:40 +02:00

41 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('posts', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->uuid('workspace_id');
$table->uuid('user_id')->nullable();
$table->text('content')->nullable();
$table->json('media')->nullable()->default(null);
$table->string('status')->default('draft');
$table->timestamp('scheduled_at')->nullable();
$table->timestamp('published_at')->nullable();
$table->timestamps();
$table->foreign('workspace_id')->references('id')->on('workspaces')->cascadeOnDelete();
$table->foreign('user_id')->references('id')->on('users')->nullOnDelete();
$table->index(['workspace_id', 'status', 'scheduled_at']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('posts');
}
};