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

Incorrect charset + collation used when generating migrations #112

Closed
laurentvd opened this issue Apr 26, 2021 · 4 comments
Closed

Incorrect charset + collation used when generating migrations #112

laurentvd opened this issue Apr 26, 2021 · 4 comments

Comments

@laurentvd
Copy link

When generating migrations, I expected it to honour the charset & collation settings for the Laravel DB connections. With newer versions of Laravel this is set to utf8mb4. However, when generating migrations, it seems to always default to DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci`.

I tried looking for a way to tell Doctrine to use utf8mb4 and was looking for something like this where you set default_table_options, but couldn't find any nor am I certain this is the correct approach. Is this is a bug? A missing feature? How can I help resolve this?

Finally, thanks a lot for all your hard work on this package. It saves all of us lots of time! Really appreciated.

@eigan
Copy link
Member

eigan commented Apr 27, 2021

There is some non-documented configuration options available:

In your config/doctrine.php

return [
    'managers' => [
        'default' => [
            'charset' => null,
            'defaultTableOptions' => [
                'charset' => null
            ],
     // ...

These configuration options are sent directly into doctrine.
See LaravelDoctrine\ORM\Configuration\Connections\MysqlConnection for available configuration keys.
And by searching for the key inside the vendor/doctrine directory can you see how they are used by doctrine.

I guess the values could be pretty similiar to how they are defined in symfony.

@laurentvd
Copy link
Author

@eigan thanks a lot! This indeed did the trick. Would you like me to make a PR to add this to the documentation? Or would you rather keep it undocumented?

@eigan
Copy link
Member

eigan commented Apr 27, 2021

Sure :)

A PR for laravel-doctrine/orm (file in config/doctrine.php) and perhaps laravel-doctrine/docs. But I have no control over the laravel-doctrine.org site and cannot update it (sadly its very far behind at the moment).

@laurentvd
Copy link
Author

I've created a PR, so let's continue there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants