Skip to content

[11.x] Non-default schema names #50019

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

Merged
merged 37 commits into from
Feb 12, 2024

Conversation

hafezdivandari
Copy link
Contributor

@hafezdivandari hafezdivandari commented Feb 8, 2024

This PR adds tests for all schema operations with prefixed table and with custom schema name. Some schema methods were not working properly in these cases that are fixed on this PR:

Prefixed table

  • Renaming a column on a prefixed table is fixed on SQL Server
  • Renaming an index on a prefixed table is fixed on SQL Server
  • Specifying a starting value for auto-incrementing column on prefixed table is fixed on PostgreSQL

Non-default Schema name

  • Dropping a primary key on non-default schema is fixed on PostgreSQL
  • Renaming a table on non-default schema is fixed on SQL Server
  • Renaming a column of a table on non-default schema is fixed on SQL Server
  • Renaming an index of a table on non-default schema is fixed on SQL Server

Prefixed table on non-default schema

Most of schema operations wasn't working on this case, that is fixed now. Grammar was always prefixing the first segment of passed values, that causes a problem when passing a table as schema.table and being wrapped as prefix_schema.table, this conditions is fixed by separating the logic for wrapping columns/values from wrapping tables after this PR:

  • table.column being wrapped to prefix_table.column using Grammar::wrap() as before.
  • schema.table being wrapped as schema.prefix_table using Grammar::wrapTable() as expected.

P.S: This is just a fix and adds support for prefixed table and using non-default schema on all cases, it's not changing behavior so we don't need to add anything to upgrade guide.

Summary of tested and fixed cases

DBPostgreSQLSQL ServerPostgreSQLSQL ServerPostgreSQLSQL Server
Feature Schema NamePrefixSchema Name + Prefix
Create Table✓ (fixed)✓ (fixed)
Rename Table✓ (fixed)✓ (fixed)✓ (fixed)
Drop Table✓ (fixed)✓ (fixed)
Has Table✓ (#49965)✓ (#49965)
Table w/ Commentn/an/a✓ (fixed)n/a
Add Column✓ (fixed)✓ (fixed)
Rename Column✓ (#45258)✓ (fixed)✓ (fixed)✓ (fixed)✓ (fixed)
Modify Column✓ (#45487)✓ (#45487)✓ (fixed)✓ (fixed)
Drop Column✓ (fixed)✓ (fixed)
Column w/ Default✓ (#49965)✓ (fixed)✓ (fixed)
Column w/ Commentn/an/a✓ (fixed)n/a
Column w/ Starting Valuen/a✓ (fixed)n/a✓ (fixed)n/a
Get Columns✓ (#49965)✓ (#49965)
Has Column(s)✓ (#49965)✓ (#49965)
Get Column Type✓ (#49965)✓ (#49965)
Add Index✓ (fixed)✓ (fixed)
Rename Index✓ (fixed)✓ (fixed)✓ (fixed)✓ (fixed)
Drop Primary✓ (fixed)✓ (fixed)✓ (fixed)
Drop Unique✓ (fixed)✓ (fixed)
Drop Index✓ (fixed)✓ (fixed)
Get Indexes✓ (#49965)✓ (#49965)
Has Index✓ (#49965)✓ (#49965)
Add Foreign Key✓ (fixed)✓ (fixed)
Drop Foreign Key✓ (fixed)✓ (fixed)
Get Foreign Keys✓ (#49965)✓ (#49965)
Has View✓ (#49965)✓ (#49965)✓ (#49965)✓ (#49965)

Copy link

github-actions bot commented Feb 8, 2024

Thanks for submitting a PR!

Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

@hafezdivandari hafezdivandari marked this pull request as ready for review February 10, 2024 14:53
@taylorotwell
Copy link
Member

Any breaking changes that will need to be documented here?

@hafezdivandari
Copy link
Contributor Author

@taylorotwell no, it's just a fix.

@hafezdivandari hafezdivandari changed the title [11.x] Test custom schema names [11.x] non-default schema names Feb 12, 2024
@hafezdivandari hafezdivandari changed the title [11.x] non-default schema names [11.x] Non-default schema names Feb 12, 2024
@taylorotwell taylorotwell merged commit 2555473 into laravel:master Feb 12, 2024
@taylorotwell
Copy link
Member

Thanks!

@hafezdivandari hafezdivandari deleted the master-custom-schema-name branch February 12, 2024 17:16
@arjenvanoostrum
Copy link
Contributor

Hi @hafezdivandari Thanks for your effort to now fully support schema names in SQLserver! Brings the database component to an even higher level.

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.

3 participants