Skip to content
Advertisement

Force doctrine datatype choice, from tinytext to varchar

I’ve describe my entity with short text properties with fixed length. When I use the command make:migration, it generates an SQL code with TINYTEXT datatype. In my case it will be more accurate to use VARCHAR, as my properties have short fixed length.

I’ve search, but I find no satisfying solutions.

I would like to indicate to Doctrine to use VARCHAR for this texts. Is it possible? How?

If I can’t : I’ve see that in the generated php code for migration that it suggests to make myself edit on the SQL generated. Could I change TINYTEXT into VARCHAR here? and will doctrine take it into account for future modifications?

JavaScript

MySQL

JavaScript

Advertisement

Answer

Doctrine maps type="text", length=64 to mysql’s TINYTEXT.

You are looking for the string type.

JavaScript

This will be mapped to VARCHAR(64)

See https://www.doctrine-project.org/projects/doctrine-dbal/en/2.10/reference/types.html#string for further reference.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement