-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Bug description
After upgrading to DBAL 4, we get a perpetual schema diff for datetime columns mapped with a custom type
(carbon_immutable) and precision="3".
Even when DB columns are already timestamp(3) without time zone, doctrine:schema:update --dump-sql keeps generating
the same ALTER TABLE ... TYPE TIMESTAMP(3) statements on every run.
Stack
- Symfony 7.3.11
- doctrine/dbal 4.4.2
- doctrine/orm 3.6.2
- doctrine/migrations 3.9.6
- doctrine/doctrine-bundle 3.2.2
- PostgreSQL 16
- carbonphp/carbon-doctrine-types 3.2.0
- XML mappings
Mapping example
<field name="createdAt" type="carbon_immutable" column="created_at_utc" precision="3" nullable="false"/>Actual result
doctrine:schema:update --dump-sql repeatedly outputs:
ALTER TABLE bitrix24account ALTER created_at_utc TYPE TIMESTAMP(3) WITHOUT TIME ZONE;
ALTER TABLE bitrix24account ALTER updated_at_utc TYPE TIMESTAMP(3) WITHOUT TIME ZONE;
-- same for other tables with carbon_immutable + precision=3
After applying migration, the same diff appears again.
doctrine:schema:validate reports DB not in sync.
What we observed
At runtime, introspection returns for such DB columns:
- type class: Doctrine\DBAL\Types\DateTimeType
- precision: NULL
But ORM metadata for the same field is:
- type: carbon_immutable
- precision: 3
So comparator appears to detect a change on every run.
Expected result
If DB column is already timestamp(3) without time zone, no diff should be generated.
Temporary workaround
Setting mapping precision to 0 for these custom datetime fields avoids the perpetual diff in our setup (but this is not
ideal as a general solution).