Closed thecrazybob closed 5 months ago
Modification to slug
field in create_pages_table.php.stub
The blueprint of the website's pages underwent a slight alteration where the website addresses (termed 'slugs') are no longer required to be unique.
Introduction of parent_id
field in create_pages_table.php.stub
A new element known as 'parent_id' has been introduced, which is combined with the 'slug' to create a unique key. This translates to better organization of the pages on the website as they're now parented and structured more effectively.
Updated Migration matching the above changes
The database changes made in the create_pages_table.php.stub
file have been synchronized with the website's database system (a process known as migration) to ensure that these improvements are reflected site-wide.
Hi thanks for noticing this bug. Please create new migration file to fix this. Avoid editing the existing migration file
Please submit a new PR fixing this
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 thepages_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
andparent_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.