-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Remove support for primary indexes #6870
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
Conversation
e45f2b4
to
bf5bb05
Compare
ad9e28e
to
50fef26
Compare
9f310c0
to
c6ea5b1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR removes support for representing primary key constraints with the Index class, reflecting deprecated features and clarifying the end-user impact with a BC break in upgrade notes.
- Documentation now explains that primary indexes are no longer returned or considered in index management.
- Several methods related to primary key constraints have been removed or adjusted (e.g. Table::getPrimaryKey, Table::setPrimaryKey, and PostgreSQLPlatform::getDropIndexSQL).
- The upgrade notes have been updated to outline the changes and impact clearly.
Files not reviewed (19)
- src/Platforms/AbstractMySQLPlatform.php: Language not supported
- src/Platforms/AbstractPlatform.php: Language not supported
- src/Platforms/DB2Platform.php: Language not supported
- src/Platforms/Exception/UnsupportedPrimaryKeyConstraintDefinition.php: Language not supported
- src/Platforms/OraclePlatform.php: Language not supported
- src/Platforms/PostgreSQLPlatform.php: Language not supported
- src/Platforms/SQLServerPlatform.php: Language not supported
- src/Platforms/SQLitePlatform.php: Language not supported
- src/Schema/AbstractSchemaManager.php: Language not supported
- src/Schema/Comparator.php: Language not supported
- src/Schema/DB2SchemaManager.php: Language not supported
- src/Schema/Exception/InvalidIndexDefinition.php: Language not supported
- src/Schema/Index.php: Language not supported
- src/Schema/MySQLSchemaManager.php: Language not supported
- src/Schema/OracleSchemaManager.php: Language not supported
- src/Schema/PostgreSQLSchemaManager.php: Language not supported
- src/Schema/PrimaryKeyConstraint.php: Language not supported
- src/Schema/SQLServerSchemaManager.php: Language not supported
- src/Schema/SQLiteSchemaManager.php: Language not supported
{ | ||
public static function fromNamedConstraint(): self | ||
{ | ||
return new self('The current database platform does not support named primary key constraints.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applications can deal with several platforms. Will it be clear enough which platform we are talking about, or should this method accept an AbstractPlatform
argument?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My assumption was that the operator of the application knows which database platform a it's deployed against, but I guess the point is that a single application may use multiple platforms (e.g. MySQL for inventory and Oracle for billing). In this case, yes, having the platform as part of the message should be helpful.
We can also include the table name and constraint name in the message. The constraint name is unavailable for unnamed constraints (in fromNonClusteredConstraint()
), and the table name is unavailable in getPrimaryKeyConstraintDeclarationSQL()
from where this exception can be thrown, so I'll just add the platform class.
The SQLServerPlatformTest::testCreateNonClusteredPrimaryKeyInTable() failure is expected here. It happens because the test mutates the primary index after adding it to the table, but that is not reflected in the primary key constraint derived from that index at the time when the index was added to the table. Tracking mutations in the index might significantly complicate the forward compatibility code and so far is considered not worth it.
This scenario is covered by AlterTableTest::testSwitchPrimaryKeyOrder()
c6ea5b1
to
b344c97
Compare
The affected features were deprecated in #6867. See the upgrade notes for details on the end-user impact.
Improvements
As a side effect, this change provides the following:
Technical details
true
as the$isPrimary
argument of theIndex
constructor but does not remove the parameter itself. Removing the parameter would require modifying code that instantiates non-PK indexes as well. Once we introduceIndexEditor
, we will mark the constructor as@internal
and then remove the parameter.Closes #807
Fixes #2294
Closes #3890