Z3d0X / filament-fabricator

Block-Based Page Builder Skeleton for your Filament Apps
https://filamentphp.com/plugins/fabricator
MIT License
251 stars 48 forks source link

Slug unique `integrity constraint violation` #134

Closed Z3d0X closed 5 months ago

Z3d0X commented 5 months ago

Original PR #133

Problem: The application threw an exception for a duplicate entry for the key pages.pages_slug_unique when attempting to insert a new page with the same slug as an existing page, but with a different parent.

Solution: The unique index on the slug column has been removed, and a new compound unique index has been introduced on the combination of slug and parent_id columns. This allows the same slug to be used as long as it has a different parent, thus ensuring unique URLs for different page hierarchies while avoiding the integrity constraint violation.

Original PR was closed because it updated the existing migration file, this way would for new installations of this package. To solve this issue for existing applications using this package a new migration must be created, for the proposed solution