Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 1 commit into from

Conversation

thecrazybob
Copy link

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.

Copy link

what-the-diff bot commented Jan 31, 2024

PR Summary

  • 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.

@Z3d0X
Copy link
Owner

Z3d0X commented Jan 31, 2024

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

  • Create a new migration file to fix unique index

@Z3d0X
Copy link
Owner

Z3d0X commented Feb 3, 2024

#134
Please submit a new PR fixing this

@Z3d0X Z3d0X closed this Feb 3, 2024
@Z3d0X Z3d0X mentioned this pull request Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants