Skip to content

Commit

Permalink
Fix Slug Unique Constraint (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
Z3d0X authored Feb 6, 2024
1 parent 8e10562 commit fe74f2c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
public function up()
{
Schema::table(config('filament-fabricator.table_name', 'pages'), function (Blueprint $table) {
$table->dropUnique(['slug']);
$table->unique(['slug', 'parent_id']);
});
}

public function down()
{
Schema::table(config('filament-fabricator.table_name', 'pages'), function (Blueprint $table) {
$table->dropUnique(['slug', 'parent_id']);
$table->unique(['slug']);
});
}
};
5 changes: 4 additions & 1 deletion src/FilamentFabricatorServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ public function configurePackage(Package $package): void
{
$package->name(FilamentFabricatorManager::ID)
->hasConfigFile()
->hasMigration('create_pages_table')
->hasMigrations(
'create_pages_table',
'fix_slug_unique_constraint_on_pages_table',
)
->hasRoute('web')
->hasViews()
->hasTranslations()
Expand Down

0 comments on commit fe74f2c

Please sign in to comment.