Skip to content

Add citext column type support for PostgreSQL#1069

Merged
LordSimal merged 1 commit into5.nextfrom
feature/pgsql-citext-column-type
Apr 19, 2026
Merged

Add citext column type support for PostgreSQL#1069
LordSimal merged 1 commit into5.nextfrom
feature/pgsql-citext-column-type

Conversation

@dereuromark
Copy link
Copy Markdown
Member

@dereuromark dereuromark commented Apr 17, 2026

Summary

Adds support for the PostgreSQL citext extension type to the migrations adapter.

The heavy lifting was already in place: Cake\Database\Schema\PostgresSchemaDialect::columnDefinitionSql() already emits CITEXT for TableSchemaInterface::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::$type passes through to isValidColumnType() via in_array($column->getType(), $this->getColumnTypes(), true), and PostgresAdapter::$specificColumnTypes did not include citext, so builder calls like

$table->addColumn('nickname', 'citext', ['null' => true])

failed with

An invalid column type "citext" was specified for column "nickname".

Changes, modelled on how cidr / inet / macaddr are wired:

  • Expose AdapterInterface::TYPE_CITEXT (mirrors TableSchemaInterface::TYPE_CITEXT)
  • Add Column::CITEXT alias
  • Include self::TYPE_CITEXT in PostgresAdapter::$specificColumnTypes
  • Add a Postgres integration test (testAddColumnCitext) — note that the test bootstrap already runs CREATE EXTENSION IF NOT EXISTS citext, which strongly suggests this support was intended
  • Add TYPE_CITEXT (expected false) to the SqliteAdapter provideColumnTypesForValidation data provider
  • Document the new type in writing-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

  • A follow-up to this would be a generic hook for registering arbitrary Postgres extension types (hstore, ltree, vector, tsvector, …). That is a larger design discussion and deliberately not included here — this PR narrowly fixes citext, which Cake core already supports.

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.
@dereuromark dereuromark added this to the 5.next milestone Apr 17, 2026
@dereuromark dereuromark marked this pull request as ready for review April 17, 2026 11:30
@LordSimal LordSimal merged commit 1dbb2f7 into 5.next Apr 19, 2026
20 checks passed
@LordSimal LordSimal deleted the feature/pgsql-citext-column-type branch April 19, 2026 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants