Missing default length on ID field type string #7348

Open
opened 2026-01-22 15:50:22 +01:00 by admin · 9 comments
Owner

Originally created by @bigfoot90 on GitHub (Mar 19, 2024).

BC Break Report

Q A
BC Break yes
Version 3.1.0

Summary

Migrating from 2.19.2 to 3.1.0 I'm getting an error running schema:diff
Error:

In InvalidColumnDeclaration.php line 17:
  Column "site_name" has invalid type  
                                       
In ColumnLengthRequired.php line 26:
  Doctrine\DBAL\Platforms\MariaDB1060Platform requires the length of a VARCHAR column to be specified  

Previous behavior

Mapping before migration:

    <entity name="Domain\Model\Entity\Site">
        <id name="name" type="string"/>
        <field name="token" unique="true"/>
    </entity>

Current behavior

Actual mapping:

    <entity name="Domain\Model\Entity\Site">
        <id name="name" type="string" length="255"/>
        <field name="token" unique="true"/>
    </entity>

Expected behavior

Be able to migrate schema without errors and don't see changes on column name length.

How to reproduce

Create an entity with Id type string.
Value 255 was the default length for type string in ORM 2.19

Originally created by @bigfoot90 on GitHub (Mar 19, 2024). <!-- Before reporting a BC break, please consult the upgrading document to make sure it's not an expected change: https://github.com/doctrine/orm/blob/2.9.x/UPGRADE.md --> ### BC Break Report | Q | A |------------ | ------ | BC Break | yes | Version | 3.1.0 #### Summary Migrating from `2.19.2` to `3.1.0` I'm getting an error running `schema:diff` **Error:** ``` In InvalidColumnDeclaration.php line 17: Column "site_name" has invalid type In ColumnLengthRequired.php line 26: Doctrine\DBAL\Platforms\MariaDB1060Platform requires the length of a VARCHAR column to be specified ``` #### Previous behavior **Mapping before migration:** ```xml <entity name="Domain\Model\Entity\Site"> <id name="name" type="string"/> <field name="token" unique="true"/> </entity> ``` #### Current behavior **Actual mapping:** ```xml <entity name="Domain\Model\Entity\Site"> <id name="name" type="string" length="255"/> <field name="token" unique="true"/> </entity> ``` #### Expected behavior Be able to migrate schema without errors and don't see changes on column `name` length. #### How to reproduce Create an entity with Id type string. Value `255` was the default length for type string in ORM 2.19
Author
Owner

@herndlm commented on GitHub (May 24, 2024):

I'm not sure if you're saying that the issue is that you need to add length now, which is expected I guess. But I had a similar problem and it turned out that an outdated cache was the reason. We have an app with a custom bootstrapped EntityManager which uses an instance of ORMSetup where we pass a Symfony FilesystemAdapter. Long story short, I had to just clear that directory and it started working.

@herndlm commented on GitHub (May 24, 2024): I'm not sure if you're saying that the issue is that you need to add `length` now, which is expected I guess. But I had a similar problem and it turned out that an outdated cache was the reason. We have an app with a custom bootstrapped `EntityManager` which uses an instance of `ORMSetup` where we pass a Symfony `FilesystemAdapter`. Long story short, I had to just clear that directory and it started working.
Author
Owner

@tarlepp commented on GitHub (Nov 9, 2024):

I'm also facing this same issue.

Tried to add length: 255 to Column attribute but after that validating schema gives me [ERROR] The database schema is not in sync with the current mapping file. error.

So next I tried to run doctrine:migrations:diff command and that gives me Cannot modify readonly property Doctrine\DBAL\Schema\Index::$options error.

Also I nuked cache after each step, and that didn't solve this issue.

Anyone has idea how to solve this issue?

@tarlepp commented on GitHub (Nov 9, 2024): I'm also facing this same issue. Tried to add `length: 255` to `Column` attribute but after that validating schema gives me `[ERROR] The database schema is not in sync with the current mapping file.` error. So next I tried to run `doctrine:migrations:diff` command and that gives me `Cannot modify readonly property Doctrine\DBAL\Schema\Index::$options` error. Also I nuked cache after each step, and that didn't solve this issue. Anyone has idea how to solve this issue?
Author
Owner

@dimadeush commented on GitHub (Jun 29, 2025):

Hello

Using the latest orm 3.4 and dbal 4.2 I have another issue with the same readonly property while executing bin/console doctrine:migrations:diff:


bin/console doctrine:migrations:diff

In EvaluatingGeneratorStrategy.php(54) : eval()'d code line 707:
                                                                                   
  Cannot indirectly modify readonly property Doctrine\DBAL\Schema\Index::$options

Anyone has idea how to solve this issue?

p.s. @tarlepp I added length and it seems now it is ok (a90042a527/src/Role/Domain/Entity/Role.php (L66)). But maybe we have different cases, not sure.....

@beberlei maybe you can help with this issue, please

@dimadeush commented on GitHub (Jun 29, 2025): Hello Using the latest orm 3.4 and dbal 4.2 I have another issue with the same readonly property while executing bin/console doctrine:migrations:diff: ``` bin/console doctrine:migrations:diff In EvaluatingGeneratorStrategy.php(54) : eval()'d code line 707: Cannot indirectly modify readonly property Doctrine\DBAL\Schema\Index::$options ``` Anyone has idea how to solve this issue? p.s. @tarlepp I added length and it seems now it is ok (https://github.com/systemsdk/docker-symfony-api/blob/a90042a527586843edb71a9cb9c1461499cafd1c/src/Role/Domain/Entity/Role.php#L66). But maybe we have different cases, not sure..... @beberlei maybe you can help with this issue, please
Author
Owner

@dimadeush commented on GitHub (Jun 29, 2025):

@tarlepp it seems the issue inside friendsofphp/proxy-manager-lts or symfony/proxy-manager-bridge:

php bin/console doctrine:migrations:diff -v 

In EvaluatingGeneratorStrategy.php(54) : eval()'d code line 707:
                                                                                   
  [Error]                                                                          
  Cannot indirectly modify readonly property Doctrine\DBAL\Schema\Index::$options  
                                                                                   

Exception trace:
  at /var/www/html/vendor/friendsofphp/proxy-manager-lts/src/ProxyManager/GeneratorStrategy/EvaluatingGeneratorStrategy.php(54) : eval()'d code:707
 Doctrine\DBAL\Schema\Index->{closure:ProxyManagerGeneratedProxy\__PM__\Doctrine\DBAL\Schema\Index\Generatedd4abe4cfbe3cf4c6ae2ef9f5303b8c8e::__get():706}() at /var/www/html/vendor/friendsofphp/proxy-manager-lts/src/ProxyManager/GeneratorStrategy/EvaluatingGeneratorStrategy.php(54) : eval()'d code:712
 ProxyManagerGeneratedProxy\__PM__\Doctrine\DBAL\Schema\Index\Generatedd4abe4cfbe3cf4c6ae2ef9f5303b8c8e->__get() at /var/www/html/vendor/doctrine/dbal/src/Schema/Index.php:312
 Doctrine\DBAL\Schema\Index->hasSameColumnLengths() at /var/www/html/vendor/doctrine/dbal/src/Schema/Index.php:192
 Doctrine\DBAL\Schema\Index->isFulfilledBy() at /var/www/html/vendor/doctrine/dbal/src/Schema/Comparator.php:433
 Doctrine\DBAL\Schema\Comparator->diffIndex() at /var/www/html/vendor/doctrine/dbal/src/Schema/Comparator.php:240
 Doctrine\DBAL\Schema\Comparator->compareTables() at /var/www/html/vendor/doctrine/dbal/src/Platforms/MySQL/Comparator.php:35
 Doctrine\DBAL\Platforms\MySQL\Comparator->compareTables() at /var/www/html/vendor/doctrine/dbal/src/Schema/Comparator.php:59
 Doctrine\DBAL\Schema\Comparator->compareSchemas() at /var/www/html/vendor/friendsofphp/proxy-manager-lts/src/ProxyManager/GeneratorStrategy/EvaluatingGeneratorStrategy.php(54) : eval()'d code:69
 ProxyManagerGeneratedProxy\__PM__\Doctrine\DBAL\Platforms\MySQL\Comparator\Generated44058fbde9aeced131f0e86f2df6e3ac->compareSchemas() at /var/www/html/vendor/doctrine/migrations/src/Generator/DiffGenerator.php:92
 Doctrine\Migrations\Generator\DiffGenerator->generate() at /var/www/html/vendor/doctrine/migrations/src/Tools/Console/Command/DiffCommand.php:141
 Doctrine\Migrations\Tools\Console\Command\DiffCommand->execute() at /var/www/html/vendor/symfony/console/Command/Command.php:318
 Symfony\Component\Console\Command\Command->run() at /var/www/html/vendor/symfony/console/Application.php:1092
 Symfony\Component\Console\Application->doRunCommand() at /var/www/html/vendor/symfony/framework-bundle/Console/Application.php:123
 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /var/www/html/vendor/symfony/console/Application.php:341
 Symfony\Component\Console\Application->doRun() at /var/www/html/vendor/symfony/framework-bundle/Console/Application.php:77
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /var/www/html/vendor/symfony/console/Application.php:192
 Symfony\Component\Console\Application->run() at /var/www/html/vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:49
 Symfony\Component\Runtime\Runner\Symfony\ConsoleApplicationRunner->run() at /var/www/html/vendor/autoload_runtime.php:29
 require_once() at /var/www/html/bin/console:1
@dimadeush commented on GitHub (Jun 29, 2025): @tarlepp it seems the issue inside [friendsofphp/proxy-manager-lts](https://packagist.org/packages/friendsofphp/proxy-manager-lts) or [symfony/proxy-manager-bridge](https://packagist.org/packages/symfony/proxy-manager-bridge): ``` php bin/console doctrine:migrations:diff -v In EvaluatingGeneratorStrategy.php(54) : eval()'d code line 707: [Error] Cannot indirectly modify readonly property Doctrine\DBAL\Schema\Index::$options Exception trace: at /var/www/html/vendor/friendsofphp/proxy-manager-lts/src/ProxyManager/GeneratorStrategy/EvaluatingGeneratorStrategy.php(54) : eval()'d code:707 Doctrine\DBAL\Schema\Index->{closure:ProxyManagerGeneratedProxy\__PM__\Doctrine\DBAL\Schema\Index\Generatedd4abe4cfbe3cf4c6ae2ef9f5303b8c8e::__get():706}() at /var/www/html/vendor/friendsofphp/proxy-manager-lts/src/ProxyManager/GeneratorStrategy/EvaluatingGeneratorStrategy.php(54) : eval()'d code:712 ProxyManagerGeneratedProxy\__PM__\Doctrine\DBAL\Schema\Index\Generatedd4abe4cfbe3cf4c6ae2ef9f5303b8c8e->__get() at /var/www/html/vendor/doctrine/dbal/src/Schema/Index.php:312 Doctrine\DBAL\Schema\Index->hasSameColumnLengths() at /var/www/html/vendor/doctrine/dbal/src/Schema/Index.php:192 Doctrine\DBAL\Schema\Index->isFulfilledBy() at /var/www/html/vendor/doctrine/dbal/src/Schema/Comparator.php:433 Doctrine\DBAL\Schema\Comparator->diffIndex() at /var/www/html/vendor/doctrine/dbal/src/Schema/Comparator.php:240 Doctrine\DBAL\Schema\Comparator->compareTables() at /var/www/html/vendor/doctrine/dbal/src/Platforms/MySQL/Comparator.php:35 Doctrine\DBAL\Platforms\MySQL\Comparator->compareTables() at /var/www/html/vendor/doctrine/dbal/src/Schema/Comparator.php:59 Doctrine\DBAL\Schema\Comparator->compareSchemas() at /var/www/html/vendor/friendsofphp/proxy-manager-lts/src/ProxyManager/GeneratorStrategy/EvaluatingGeneratorStrategy.php(54) : eval()'d code:69 ProxyManagerGeneratedProxy\__PM__\Doctrine\DBAL\Platforms\MySQL\Comparator\Generated44058fbde9aeced131f0e86f2df6e3ac->compareSchemas() at /var/www/html/vendor/doctrine/migrations/src/Generator/DiffGenerator.php:92 Doctrine\Migrations\Generator\DiffGenerator->generate() at /var/www/html/vendor/doctrine/migrations/src/Tools/Console/Command/DiffCommand.php:141 Doctrine\Migrations\Tools\Console\Command\DiffCommand->execute() at /var/www/html/vendor/symfony/console/Command/Command.php:318 Symfony\Component\Console\Command\Command->run() at /var/www/html/vendor/symfony/console/Application.php:1092 Symfony\Component\Console\Application->doRunCommand() at /var/www/html/vendor/symfony/framework-bundle/Console/Application.php:123 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /var/www/html/vendor/symfony/console/Application.php:341 Symfony\Component\Console\Application->doRun() at /var/www/html/vendor/symfony/framework-bundle/Console/Application.php:77 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /var/www/html/vendor/symfony/console/Application.php:192 Symfony\Component\Console\Application->run() at /var/www/html/vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:49 Symfony\Component\Runtime\Runner\Symfony\ConsoleApplicationRunner->run() at /var/www/html/vendor/autoload_runtime.php:29 require_once() at /var/www/html/bin/console:1 ```
Author
Owner

@greg0ire commented on GitHub (Jun 29, 2025):

@dimadeush then maybe you should try updating to a recent doctrine/migration version? It does not rely on those libraries since https://github.com/doctrine/migrations/pull/1273, which was released in 3.6.0

@greg0ire commented on GitHub (Jun 29, 2025): @dimadeush then maybe you should try updating to a recent `doctrine/migration` version? It does not rely on those libraries since https://github.com/doctrine/migrations/pull/1273, which was released in 3.6.0
Author
Owner

@dimadeush commented on GitHub (Jun 30, 2025):

@greg0ire we are using the latest version of doctrine/migration. We have additional services that are using mentioned above bundle, f.e. like the next https://medium.marco.zone/add-the-symfony-stopwatch-to-services-without-changing-them-e52266df0df1.

@dimadeush commented on GitHub (Jun 30, 2025): @greg0ire we are using the latest version of doctrine/migration. We have additional services that are using mentioned above bundle, f.e. like the next https://medium.marco.zone/add-the-symfony-stopwatch-to-services-without-changing-them-e52266df0df1.
Author
Owner

@dimadeush commented on GitHub (Jun 30, 2025):

@tarlepp Maybe the best way to solve this issue just put Doctrine\DBAL\Schema\Index into ignore for the StopwatchDecorator - https://github.com/systemsdk/docker-symfony-api/blob/3.6.x/src/General/Application/Decorator/StopwatchDecorator.php#L44

@greg0ire now migrations:diff is working properly with the latest orm 3.4 and dbal 4.2, thanks.

@dimadeush commented on GitHub (Jun 30, 2025): @tarlepp Maybe the best way to solve this issue just put `Doctrine\DBAL\Schema\Index` into ignore for the StopwatchDecorator - https://github.com/systemsdk/docker-symfony-api/blob/3.6.x/src/General/Application/Decorator/StopwatchDecorator.php#L44 @greg0ire now migrations:diff is working properly with the latest orm 3.4 and dbal 4.2, thanks.
Author
Owner

@Adi-18 commented on GitHub (Jan 10, 2026):

Same problem

In InvalidColumnDeclaration.php line 16:
  Column "role_groups_id" has invalid type  
                                            

In ColumnLengthRequired.php line 22:
  Doctrine\DBAL\Platforms\MariaDBPlatform requires the length of a VARCHAR column to be specified  

Fielddefinition:

class RoleEntity
{
    #[ORM\Id]
    #[ORM\Column(name: "id", type: "string", length: 255)]
    private string $id = "";

    ...
}
-----------------------------------------
class AuthorityRole
{

    ...

    #[ORM\Id]
    #[ORM\ManyToOne(targetEntity: RoleEntity::class, inversedBy: "authorityRole")]
    #[ORM\JoinColumn(name: "role_entity_id", referencedColumnName: "id", nullable: false)]
    private RoleEntity $roleEntity;

    ...
}

@tarlepp Maybe the best way to solve this issue just put Doctrine\DBAL\Schema\Index into ignore for the StopwatchDecorator - https://github.com/systemsdk/docker-symfony-api/blob/3.6.x/src/General/Application/Decorator/StopwatchDecorator.php#L44

@greg0ire now migrations:diff is working properly with the latest orm 3.4 and dbal 4.2, thanks.

Link did not help because of "404 - page not found"

@Adi-18 commented on GitHub (Jan 10, 2026): Same problem ``` In InvalidColumnDeclaration.php line 16: Column "role_groups_id" has invalid type In ColumnLengthRequired.php line 22: Doctrine\DBAL\Platforms\MariaDBPlatform requires the length of a VARCHAR column to be specified ``` Fielddefinition: ``` class RoleEntity { #[ORM\Id] #[ORM\Column(name: "id", type: "string", length: 255)] private string $id = ""; ... } ----------------------------------------- class AuthorityRole { ... #[ORM\Id] #[ORM\ManyToOne(targetEntity: RoleEntity::class, inversedBy: "authorityRole")] #[ORM\JoinColumn(name: "role_entity_id", referencedColumnName: "id", nullable: false)] private RoleEntity $roleEntity; ... } ``` > [@tarlepp](https://github.com/tarlepp) Maybe the best way to solve this issue just put `Doctrine\DBAL\Schema\Index` into ignore for the StopwatchDecorator - https://github.com/systemsdk/docker-symfony-api/blob/3.6.x/src/General/Application/Decorator/StopwatchDecorator.php#L44 > > [@greg0ire](https://github.com/greg0ire) now migrations:diff is working properly with the latest orm 3.4 and dbal 4.2, thanks. Link did not help because of "404 - page not found"
Author
Owner

@dimadeush commented on GitHub (Jan 10, 2026):

Same problem

In InvalidColumnDeclaration.php line 16:
  Column "role_groups_id" has invalid type  
                                            

In ColumnLengthRequired.php line 22:
  Doctrine\DBAL\Platforms\MariaDBPlatform requires the length of a VARCHAR column to be specified  

Fielddefinition:

class RoleEntity
{
    #[ORM\Id]
    #[ORM\Column(name: "id", type: "string", length: 255)]
    private string $id = "";

    ...
}
-----------------------------------------
class AuthorityRole
{

    ...

    #[ORM\Id]
    #[ORM\ManyToOne(targetEntity: RoleEntity::class, inversedBy: "authorityRole")]
    #[ORM\JoinColumn(name: "role_entity_id", referencedColumnName: "id", nullable: false)]
    private RoleEntity $roleEntity;

    ...
}

@tarlepp Maybe the best way to solve this issue just put Doctrine\DBAL\Schema\Index into ignore for the StopwatchDecorator - https://github.com/systemsdk/docker-symfony-api/blob/3.6.x/src/General/Application/Decorator/StopwatchDecorator.php#L44
@greg0ire now migrations:diff is working properly with the latest orm 3.4 and dbal 4.2, thanks.

Link did not help because of "404 - page not found"

New link is - https://github.com/systemsdk/docker-symfony-api/blob/master/src/General/Application/Decorator/StopwatchDecorator.php#L45

If you have something like that - please try to use.

@dimadeush commented on GitHub (Jan 10, 2026): > Same problem > > ``` > In InvalidColumnDeclaration.php line 16: > Column "role_groups_id" has invalid type > > > In ColumnLengthRequired.php line 22: > Doctrine\DBAL\Platforms\MariaDBPlatform requires the length of a VARCHAR column to be specified > ``` > > Fielddefinition: > > ``` > class RoleEntity > { > #[ORM\Id] > #[ORM\Column(name: "id", type: "string", length: 255)] > private string $id = ""; > > ... > } > ----------------------------------------- > class AuthorityRole > { > > ... > > #[ORM\Id] > #[ORM\ManyToOne(targetEntity: RoleEntity::class, inversedBy: "authorityRole")] > #[ORM\JoinColumn(name: "role_entity_id", referencedColumnName: "id", nullable: false)] > private RoleEntity $roleEntity; > > ... > } > ``` > > > [@tarlepp](https://github.com/tarlepp) Maybe the best way to solve this issue just put `Doctrine\DBAL\Schema\Index` into ignore for the StopwatchDecorator - https://github.com/systemsdk/docker-symfony-api/blob/3.6.x/src/General/Application/Decorator/StopwatchDecorator.php#L44 > > [@greg0ire](https://github.com/greg0ire) now migrations:diff is working properly with the latest orm 3.4 and dbal 4.2, thanks. > > Link did not help because of "404 - page not found" New link is - https://github.com/systemsdk/docker-symfony-api/blob/master/src/General/Application/Decorator/StopwatchDecorator.php#L45 If you have something like that - please try to use.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7348