59 lines
2.0 KiB
PHP
59 lines
2.0 KiB
PHP
<?php
|
|
|
|
use Database\Seeders\CmsSeeder;
|
|
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('pages', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->string('path')->unique();
|
|
$table->unsignedBigInteger('published_revision_id')->nullable();
|
|
$table->timestamps();
|
|
});
|
|
|
|
Schema::create('page_revisions', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->foreignId('page_id')->constrained()->cascadeOnDelete();
|
|
$table->json('blocks');
|
|
$table->string('seo_title')->nullable();
|
|
$table->string('seo_description', 500)->nullable();
|
|
$table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
|
|
$table->timestamp('created_at')->useCurrent();
|
|
});
|
|
|
|
Schema::table('pages', function (Blueprint $table) {
|
|
$table->foreign('published_revision_id')
|
|
->references('id')
|
|
->on('page_revisions')
|
|
->nullOnDelete();
|
|
});
|
|
|
|
Schema::create('navigation_items', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->string('label');
|
|
$table->foreignId('page_id')->nullable()->constrained()->nullOnDelete();
|
|
$table->string('url')->nullable();
|
|
$table->string('placement')->default('header');
|
|
$table->unsignedInteger('sort_order')->default(0);
|
|
$table->timestamps();
|
|
});
|
|
|
|
(new CmsSeeder)->run();
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('navigation_items');
|
|
Schema::table('pages', function (Blueprint $table) {
|
|
$table->dropForeign(['published_revision_id']);
|
|
});
|
|
Schema::dropIfExists('page_revisions');
|
|
Schema::dropIfExists('pages');
|
|
}
|
|
};
|