migrations icon indicating copy to clipboard operation
migrations copied to clipboard

[postgres] migration_diff, "timestamptimezone" is not a valid column option

Open Rakasch opened this issue 2 months ago • 0 comments

I run cakephp 5.2.9 with a postgres DB (postgresSQL 18.1).

I added a new 'created' column with type timestamptz to a table :

Image

I generated a new migration file with the bake tool.

bin/cake bake migration_diff ...

The generated migation has this code in the up function:

            ->addColumn('created', 'timestamptimezone', [
                'default' => null,
                'limit' => null,
                'null' => true,
                'precision' => 6,
                'scale' => 6,
            ])

When I try to use the migration

bin/cake migrations migrate

I get the following error: An invalid column type "timestamptimezone" was specified for column "created".

Image

I tried to manually change it to something else. "timestamptz" is also an invalid option. With "timestamp", the migration can be executed but creates a column with timestamp(6).

First: What is the value for the migration to generate a timestamptz column? Second: Would be nice, if the migration_diff would be updated to use that / or the migrate to use timestamptimezone correctly


I also noticed something maybe related, when i checked the other migrations. In my initial snapshot, all timestamptz columns in my database were transferred to the migration as type ‘timestamp’, so without the timezone.

bin/cake bake migration_snapshot Initial


Versions: "cakephp/cakephp": 5.2.9 "cakephp/migrations": 4.9.1 "cakephp/plugin-installer": 2.0.1 "cnizzardini/cakephp-swagger-bake": 3.3.4 "cakephp/bake": 3.5.1 "cakephp/cakephp-codesniffer": 5.3.0 "cakephp/debug_kit": 5.2.1 "dereuromark/cakephp-ide-helper": 2.14.0

Rakasch avatar Dec 09 '25 12:12 Rakasch