I use doctrine ORM version 2.20.1 and migrations 3.3.1. in a Symfony6 project with php8.2.
My Entity has the following properties:
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
class CompanyDetail
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(type: Types::STRING, length: 255)]
private string $name;
#[ORM\Column(type: Types::TEXT, length: 65535)]
private string $registration;
[...]
When I create my migrations file with the usual bin/console do:mi:di
the column for the registration field is always a VARCHAR(500) like this: registration VARCHAR(500) NOT NULL,
What are the correct settings to achieve a text column?
What I did, which made it somehow happen was the following: I upgraded all doctrine packages:
"doctrine/annotations": "^2.0.2",
"doctrine/dbal": "^4.2.1",
"doctrine/doctrine-bundle": "^2.13.1",
"doctrine/doctrine-fixtures-bundle": "^4.0.0",
"doctrine/doctrine-migrations-bundle": "^3.3.1",
"doctrine/orm": "^3.3.1",
Then I defined the property as text without any length:
#[ORM\Column(type: Types::TEXT)]
private string $registration;
This gave me in the migration a LONGTEXT field. That is much longer than I need, but since this is a small table I will just take it.
However if someone has the answer on how to create a TEXT field I would still appreciate it.