-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
5.2 - Improve schema reflection #18123
Labels
Milestone
Comments
markstory
added a commit
that referenced
this issue
Jan 12, 2025
I want to use cake's schema reflection more extensively in migrations. This will let us reduce the number of schema reflection implementations we need to maintain by one, and also give the framework an improved schema reflection toolkit. Refs #18123
markstory
added a commit
that referenced
this issue
Jan 15, 2025
I don't want to break the abstract interface between dialect operations right now, so I'm using a `TableSchema` to shim operations together. Refs #18123
markstory
added a commit
that referenced
this issue
Jan 18, 2025
Add more of the api from #18123. This formalizes an array API for index reflection. Because `TableSchema` is being used to shim dialects together, we need to reflect the columns in order to build index data.
markstory
added a commit
that referenced
this issue
Jan 19, 2025
Another step of #18123. TableSchema requires columns to be present for foreignkeys to reference them. This requires reflecting columns in order to get foreign key data. I'm planning on doing more refactoring on SchemaDialect to remove the ephemeral `TableSchema` and to avoid reflecting columns for indexes and foreign keys once all the new reflection methods are complete.
markstory
added a commit
that referenced
this issue
Jan 20, 2025
This was referenced Jan 20, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
Currently both migrations and cakephp/database include logic for schema reflection. While I've been able to use cakephp/database for most schema reflection, there still are some gaps and awkwardness in the APIs that cakephp/database provides. As a result, migrations still requires some of its own schema reflection logic.
We could improve this situation and provide a more complete suite of schema reflection methods by expanding the API of
Cake\Database\Schema\SchemaDialect
to include higher-level reflection methods.Why more array return values?
The current methods on TableSchema for operating on columns, indexes, and constraints all use arrays. The new methods would also use arrays to be consistent and compatible with other methods in TableSchema.
Adding object return values to existing methods is hard because of backwards compatibility. Adding objects for columns, indexes and constraints is an option for the new methods. However, it would result in an inconsistent API for both
TableSchema
andSchemaDialect
.Breaking changes and deprecations
There would be no breaking changes required in 5.x as none of the existing public methods would be changed. With new higher-level
methods being added, we could deprecate the existing
describe*
andconvert*
methods:The usage of these methods can be replaced with usage of the new higher-level methods. This would improve the public API of
SchemaDialect
as the proposed methods are simpler to operate than the existingdescribe*
andconvert*
methods.CakePHP Version
5.2
The text was updated successfully, but these errors were encountered: