diff --git a/doctrine.rst b/doctrine.rst index 00de1cf1b58..baafcace6c4 100644 --- a/doctrine.rst +++ b/doctrine.rst @@ -149,6 +149,15 @@ can automatically generate an empty ``test_project`` database for you: support 4-byte unicode characters, and strings containing them will be truncated. This is fixed by the `newer utf8mb4 character set`_. + .. caution:: + + MySQL sets a `limit of 767 bytes for the index key prefix`_. When using + ``utf8mb4``, string columns with 255 character length surpass that limit. + This means that any column of type ``string`` and ``unique=true`` must + set its maximum ``length`` to ``190``. Otherwise, you'll see this error: + *"[PDOException] SQLSTATE[42000]: Syntax error or access violation: + 1071 Specified key was too long; max key length is 767 bytes"*. + .. note:: If you want to use SQLite as your database, you need to set the path @@ -838,3 +847,4 @@ Learn more .. _`FrameworkExtraBundle documentation`: https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html .. _`newer utf8mb4 character set`: https://dev.mysql.com/doc/refman/5.5/en/charset-unicode-utf8mb4.html .. _`Transactions and Concurrency`: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/transactions-and-concurrency.html +.. _`limit of 767 bytes for the index key prefix`: https://dev.mysql.com/doc/refman/5.6/en/innodb-restrictions.html