Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

tomcodes's avatar

Unknown database type citext requested error when making some fields nullable

Hello!

I am working on a migration that is supposed to make some existing fields nullable.

Here is a snippet of the migration:

Schema::table('user', function (Blueprint $table) {
    $table->string('firstname')->nullable()->change();
});

When I run it, I have the following error in my terminal:

Doctrine\DBAL\Exception 

Unknown database type citext requested, Doctrine\DBAL\Platforms\PostgreSQL100Platform may not support it.

I have enabled citextextension in the past to be able to case-insensitive-search in the DB:

DB::statement('CREATE EXTENSION IF NOT EXISTS citext;');
DB::statement('ALTER TABLE user ALTER COLUMN email TYPE citext');

I don't see what I am doing wrong. Could anyone help me please?

[EDIT] - Minor tweaks, fixed typos

0 likes
1 reply
tpetry's avatar

My reply is pretty late but i did find your question just a few days ago because i got the same error.

When laravel is changing the structure of a table (making your firstname nullable) the information for every column of the table is loaded and doctrine dbal has to calculate the difference between your actual version and your desired version. But doctrine is not aware of the citext data type so it is unable to calculate the needed sql queries for transforming your column. You have to write a type definition for the citext type so doctrine dbal does know how to handle the column.

As i said before i had the same problem, so i did make a package which adds all these postgresql specific column types to laravel so you can use in migrations without any problems: https://github.com/tpetry/laravel-postgresql-enhanced

1 like

Please or to participate in this conversation.