Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.0] MariaDB: The default version column length is too long #247

Closed
mhujer opened this issue Dec 22, 2018 · 4 comments · Fixed by #249
Closed

[2.0] MariaDB: The default version column length is too long #247

mhujer opened this issue Dec 22, 2018 · 4 comments · Fixed by #249

Comments

@mhujer
Copy link

mhujer commented Dec 22, 2018

Summary

When MariaDB is used and Migrations 2.0 are installed to a new Symfony application with default Doctrine configuration, creating a migration will fail.

Related issues: doctrine/migrations#514 and doctrine/migrations#538

Current behavior

Error message is displayed when creating a migration diff:

An exception occurred while executing 'CREATE TABLE migration_versions (version VARCHAR(255) NOT NULL, executed_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', PRIMARY KEY(version)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB':

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

How to reproduce

  1. create a new Symfony application
  2. install DoctrineORM + Doctrine Bundle
  3. install Migrations Bundle
  4. Run doctrine:migrations:diff

Expected behavior

The migration_versions table is created without failing on error.

Workaround

Add column_length: 14 to config/packages/doctrine_migrations.yaml

Proposed solution

Change default value in

->scalarNode('column_length')->defaultValue(255)->end()
from 255 to 14. The configuration reference suggests that the default is 14.

@jwage
Copy link
Member

jwage commented Jan 2, 2019

Thanks @mhujer! I have made these changes here doctrine/migrations#773 and here #249

@greg0ire
Copy link
Member

greg0ire commented Jan 2, 2019

That length is oddly specific. It was introduced in https://github.com/doctrine/DoctrineMigrationsBundle/pull/228/files#diff-fdd764ee72f777e180ace83412a44158R61 , not sure why…

@jwage
Copy link
Member

jwage commented Jan 2, 2019

I believe it is because the version string we generate by default is 14 characters long.

@greg0ire
Copy link
Member

greg0ire commented Jan 2, 2019

Indeed

>>> strlen((new \DateTime())->format('YmdHis'))
=> 14

👍

@jwage jwage closed this as completed in #249 Jan 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants