Skip to content

[10.x] Fix issue with table prefix duplication in DatabaseTruncation trait - #48291

Merged
taylorotwell merged 3 commits into
laravel:10.xfrom
mobidev86:fix/database-truncation-table-prefix
Sep 4, 2023
Merged

[10.x] Fix issue with table prefix duplication in DatabaseTruncation trait#48291
taylorotwell merged 3 commits into
laravel:10.xfrom
mobidev86:fix/database-truncation-table-prefix

Conversation

@mobidev86

Copy link
Copy Markdown
Contributor

This pull request addresses the issue documented in #48264
where the DatabaseTruncation trait would attempt to truncate a table with a prefix being applied twice when using a DB connection configured to prefix all tables.

Changes Made:

  • Added a new function removeTablePrefix to remove the table prefix from a table name if it exists.
  • Modified the truncateTablesForConnection method to utilize removeTablePrefix when checking for table existence and performing truncation.

Steps to Reproduce:

  • More details has been provided in the issue itself

Expected Outcome:

  • With this pull request, tests should pass successfully, and the issue with table prefix duplication should be resolved.

Additional Context:

  • This change ensures that the table prefix is correctly handled when checking for table existence and performing truncation, preventing the issue where the prefix was applied twice.

Testing:

  • I have tested this fix with the steps mentioned in the "Steps to Reproduce" section and confirmed that the tests now pass as expected.

@taylorotwell
taylorotwell merged commit cdf9dba into laravel:10.x Sep 4, 2023
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.

2 participants