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

Fix for Duplicate Entry SQL Error on 'pages' Table #133

Closed thecrazybob closed 5 months ago

thecrazybob commented 5 months ago

This PR addresses a SQLSTATE[23000] integrity constraint violation error encountered when inserting a new page with a non-unique slug into the pages table. The error was caused by the pages_slug_unique constraint on the slug column.

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.

what-the-diff[bot] commented 5 months ago

PR Summary

Z3d0X commented 5 months ago

Hi thanks for noticing this bug. Please create new migration file to fix this. Avoid editing the existing migration file

Z3d0X commented 5 months ago

134

Please submit a new PR fixing this