Add citext column type support for PostgreSQL#1069
Merged
Conversation
The citext extension type is already supported end-to-end by the Cake core schema dialect (DDL generation and reflection), but the migrations adapter did not expose a constant and rejected the type in isValidColumnType(). Add TYPE_CITEXT to AdapterInterface, a Column::CITEXT alias, and allow it through PostgresAdapter.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for the PostgreSQL
citextextension type to the migrations adapter.The heavy lifting was already in place:
Cake\Database\Schema\PostgresSchemaDialect::columnDefinitionSql()already emitsCITEXTforTableSchemaInterface::TYPE_CITEXT, and schema reflection already handles it (see line 147 of that dialect). The only thing blocking the type from reaching the dialect was the migrations adapter itself —Column::$typepasses through toisValidColumnType()viain_array($column->getType(), $this->getColumnTypes(), true), andPostgresAdapter::$specificColumnTypesdid not includecitext, so builder calls likefailed with
Changes, modelled on how
cidr/inet/macaddrare wired:AdapterInterface::TYPE_CITEXT(mirrorsTableSchemaInterface::TYPE_CITEXT)Column::CITEXTaliasself::TYPE_CITEXTinPostgresAdapter::$specificColumnTypestestAddColumnCitext) — note that the test bootstrap already runsCREATE EXTENSION IF NOT EXISTS citext, which strongly suggests this support was intendedTYPE_CITEXT(expectedfalse) to the SqliteAdapterprovideColumnTypesForValidationdata providerwriting-migrations.md, noting that the user still needs to enable the extension on the database (the migration will not create it automatically)No changes to DDL generation are needed — that already works end-to-end through the Cake dialect.
Notes
hstore,ltree,vector,tsvector, …). That is a larger design discussion and deliberately not included here — this PR narrowly fixescitext, which Cake core already supports.