diff --git a/database/migrations/2026_09_25_000000_create_lazy_pages_table.php b/database/migrations/2026_09_25_000000_create_lazy_pages_table.php index a2f964a..9b56626 100644 --- a/database/migrations/2026_09_25_000000_create_lazy_pages_table.php +++ b/database/migrations/2026_09_25_000000_create_lazy_pages_table.php @@ -11,7 +11,8 @@ public function up(): void $pages = (string) config('lazy-page.tables.pages', 'lazy_pages'); $translations = (string) config('lazy-page.tables.translations', 'lazy_page_translations'); - Schema::create($pages, function (Blueprint $table) use ($pages): void { + if (! Schema::hasTable($pages)) { + Schema::create($pages, function (Blueprint $table) use ($pages): void { $table->id(); $table->foreignId('parent_id')->nullable()->constrained($pages)->nullOnDelete(); $table->string('key')->nullable()->unique(); @@ -23,10 +24,12 @@ public function up(): void $table->timestamp('expires_at')->nullable()->index(); $table->unsignedInteger('position')->default(0)->index(); $table->timestamps(); - $table->softDeletes(); - }); + $table->softDeletes(); + }); + } - Schema::create($translations, function (Blueprint $table) use ($pages): void { + if (! Schema::hasTable($translations)) { + Schema::create($translations, function (Blueprint $table) use ($pages): void { $table->id(); $table->foreignId('page_id')->constrained($pages)->cascadeOnDelete(); $table->string('locale', 10)->index(); @@ -35,8 +38,9 @@ public function up(): void $table->longText('content')->nullable(); $table->timestamps(); - $table->unique(['page_id', 'locale']); - }); + $table->unique(['page_id', 'locale']); + }); + } } public function down(): void