When using a backed enum, Doctrine always generates diff to change column type #7108

Closed
opened 2026-01-22 15:44:48 +01:00 by admin · 9 comments
Owner

Originally created by @emodric on GitHub (Feb 7, 2023).

Bug Report

Q A
BC Break no
Version 2.14.1

Summary

doctrine:schema:update command constantly generates diff to change column type of my backed enum.

Current behavior

$ php bin/console doctrine:schema:update --dump-sql


 [WARNING] Not passing the "--complete" option to "orm:schema-tool:update" is deprecated and will not be supported when 
           using doctrine/dbal 4                                                                                        


ALTER TABLE app_conversation CHANGE type type INT NOT NULL;

How to reproduce

My property:

#[ORM\Column(type: Types::INTEGER, enumType: ConversationType::class)]
private ConversationType $type;

My enum:

<?php

declare(strict_types=1);

namespace App\Entity\Conversation;

enum ConversationType: int
{
    case SINGLE = 1;
    case GROUP = 2;
}

Expected behavior

I would expect that doctrine:schema:update command reports no changes in the diff.

Originally created by @emodric on GitHub (Feb 7, 2023). ### Bug Report | Q | A |------------ | ------ | BC Break | no | Version | 2.14.1 #### Summary `doctrine:schema:update` command constantly generates diff to change column type of my backed enum. #### Current behavior ``` $ php bin/console doctrine:schema:update --dump-sql [WARNING] Not passing the "--complete" option to "orm:schema-tool:update" is deprecated and will not be supported when using doctrine/dbal 4 ALTER TABLE app_conversation CHANGE type type INT NOT NULL; ``` #### How to reproduce My property: ```php #[ORM\Column(type: Types::INTEGER, enumType: ConversationType::class)] private ConversationType $type; ``` My enum: ```php <?php declare(strict_types=1); namespace App\Entity\Conversation; enum ConversationType: int { case SINGLE = 1; case GROUP = 2; } ``` #### Expected behavior I would expect that `doctrine:schema:update` command reports no changes in the diff.
admin closed this issue 2026-01-22 15:44:48 +01:00
Author
Owner

@yceruto commented on GitHub (Mar 22, 2023):

Facing the same issue... It appears that the command is unable to detect the enum type when creating the schema for comparison (the one from the database). However, the schema from the metadata detects it correctly and stores this information in _customSchemaOptions['enumType']. As a result, the schemas do not match, and a difference always exists.

The question at hand is whether we should add enumType as a known column option in Doctrine\ORM\Tools\SchemaTool::KNOWN_COLUMN_OPTIONS to prevent this persistent difference.

@yceruto commented on GitHub (Mar 22, 2023): Facing the same issue... It appears that the command is unable to detect the enum type when creating the schema for comparison (the one from the database). However, the schema from the metadata detects it correctly and stores this information in `_customSchemaOptions['enumType']`. As a result, the schemas do not match, and a difference always exists. The question at hand is whether we should add `enumType` as a known column option in `Doctrine\ORM\Tools\SchemaTool::KNOWN_COLUMN_OPTIONS` to prevent this persistent difference.
Author
Owner

@kkevindev commented on GitHub (Apr 4, 2023):

Seems to be a problem with doctrine/dbal@2, doctrine/dbal@3 should fix it. See https://github.com/Sylius/Sylius/issues/14097 for reference.

What is your doctrine/dbal version @emodric?

@kkevindev commented on GitHub (Apr 4, 2023): Seems to be a problem with `doctrine/dbal@2`, `doctrine/dbal@3` should fix it. See https://github.com/Sylius/Sylius/issues/14097 for reference. What is your `doctrine/dbal` version @emodric?
Author
Owner

@emodric commented on GitHub (Apr 4, 2023):

It's indeed latest 2.x, but I can't migrate to v3, due to some deps relying on 2.x.

@emodric commented on GitHub (Apr 4, 2023): It's indeed latest 2.x, but I can't migrate to v3, due to some deps relying on 2.x.
Author
Owner

@derrabus commented on GitHub (Apr 4, 2023):

Okay, is anyone here having this issue with DBAL 3? Otherwise, I don't think we should waste any more time on this issue.

@derrabus commented on GitHub (Apr 4, 2023): Okay, is anyone here having this issue with DBAL 3? Otherwise, I don't think we should waste any more time on this issue.
Author
Owner

@emodric commented on GitHub (Apr 5, 2023):

@derrabus Does this mean that this will not be fixed in DBAL 2.x? Is DBAL 2.x not maintained any more?

@emodric commented on GitHub (Apr 5, 2023): @derrabus Does this mean that this will not be fixed in DBAL 2.x? Is DBAL 2.x not maintained any more?
Author
Owner

@greg0ire commented on GitHub (Apr 5, 2023):

2 days ago was the first anniversary of DBAL 2.x not being maintained: https://www.doctrine-project.org/2022/01/22/sunsetting-dbal-2.html

Consider upgrading.

@greg0ire commented on GitHub (Apr 5, 2023): 2 days ago was the first anniversary of DBAL 2.x not being maintained: https://www.doctrine-project.org/2022/01/22/sunsetting-dbal-2.html Consider upgrading.
Author
Owner

@emodric commented on GitHub (Apr 5, 2023):

Whoops, I was not aware :)

As I said, a dependncy is blocking the upgrade, so not much I can do about it, unfortunately.

Thanks anyway!

@emodric commented on GitHub (Apr 5, 2023): Whoops, I was not aware :) As I said, a dependncy is blocking the upgrade, so not much I can do about it, unfortunately. Thanks anyway!
Author
Owner

@derrabus commented on GitHub (Apr 5, 2023):

As I said, a dependncy is blocking the upgrade, so not much I can do about it, unfortunately.

You can encourage or help the maintainer of that dependency to unblock you or replace that dependency in your codebase. This is what you can do and that's more than we can do in that regard. 🙂

@derrabus commented on GitHub (Apr 5, 2023): > As I said, a dependncy is blocking the upgrade, so not much I can do about it, unfortunately. You can encourage or help the maintainer of that dependency to unblock you or replace that dependency in your codebase. This is what you can do and that's more than we can do in that regard. 🙂
Author
Owner

@emodric commented on GitHub (Apr 6, 2023):

Yep, that's all I can do at this point!

@emodric commented on GitHub (Apr 6, 2023): Yep, that's all I can do at this point!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7108