1

Every time I create a new Entity with attributes as the type string, whenever I wish to update my database I receive the error:

SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes

Now this is something many people have faced and reasons are described here. I understand what my problem is and I can solve it by giving the property @ORM\Column(type="string", length=191).

I have to set the length to 191 for every single string type in my schema though. Is there any way though I can set the default length for a string to 191 in a (doctrine) config file so I don't have to change this every single time?

I do not wish to change to utf8.

Dirk J. Faber
  • 3,806
  • 3
  • 16
  • 44
  • Possible duplicate of [How to fix MySql: index column size too large (Laravel migrate)](https://stackoverflow.com/questions/42043205/how-to-fix-mysql-index-column-size-too-large-laravel-migrate) – dbrumann Feb 23 '19 at 15:27
  • You can change the configuration for MySQL to increase the available size: https://stackoverflow.com/questions/42043205/how-to-fix-mysql-index-column-size-too-large-laravel-migrate/52778785#52778785 – dbrumann Feb 23 '19 at 15:28
  • Did you solve it? – miguelbemartin Aug 15 '19 at 14:13
  • 1
    @miguelbemartin, yes. Updating my database server (MariaDB) to version 10.3.15 solved my problem. – Dirk J. Faber Aug 15 '19 at 18:02

1 Answers1

0

For Symfony 6+ code below may help. Just set length for column with migration name in doctrine_migrations.yaml:

doctrine_migrations:
  storage:
    table_storage:
        table_name: 'migration_version'
        version_column_name: 'version'
        version_column_length: 255
        executed_at_column_name: 'executed_at'
AGriboed
  • 500
  • 3
  • 5