trypost/database/migrations/2026_01_14_232318_create_posts_table.php

38 lines
1.1 KiB
PHP

<?php
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');
$table->string('status')->default('draft');
$table->boolean('synced');
$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')->cascadeOnDelete();
$table->index(['workspace_id', 'status', 'scheduled_at']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('posts');
}
};