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

Issue with migrations on MariaDB 10.2 #320

Closed
nover opened this issue Jul 12, 2017 · 14 comments
Closed

Issue with migrations on MariaDB 10.2 #320

nover opened this issue Jul 12, 2017 · 14 comments

Comments

@nover
Copy link
Contributor

nover commented Jul 12, 2017

Steps to reproduce

On an existing EF model with a foreign key to one table, change that foreign key to another table - this caused EF to create a "RENAME INDEX" in my case as the column name changes.

The issue

When renaming indexes MySQL 5.7 introduced a new nice keyword RENAME INDEX TO - however, Mariadb 10.2 does not support this, so the generated migration fail.

I was hoping that the MySQL connector could see / guess that it's not talking to MySQL 5.7 and create a migration that would apply cleanly - something like DROP and CREATE index though it is a slower.

Doctrine - an ORM for PHP had a similar issue:
doctrine/migrations#196

Further technical details

MySQL version: MariaDB 10.2.6
Operating system: Windows 10 with database via Docker Compose
Pomelo.EntityFrameworkCore.MySql version: 1.1.2

Now I know that the driver says it is MySQL compatible, but given that MariaDB is so close to being binary compatible with MySQL I was hoping you would look into fixing this.

@yukozh
Copy link
Member

yukozh commented Jul 12, 2017

Yes, this was by design. rename operations only works with 5.7+. We do not want to drop and re-create.

@nover
Copy link
Contributor Author

nover commented Jul 12, 2017

Okay, so the driver basically supports MYSQL 5.7, with no intention to support older versions of MYSQL nor mariadb?

@caleblloyd
Copy link
Contributor

Okay, so the driver basically supports MYSQL 5.7, with no intention to support older versions of MYSQL nor mariadb?

No


The migration operation is here in MySqlMigrationsSqlGenerator.cs

A server version flag needs to be added here in ServerVersion.cs for SupportsRenameIndex

Then the migration option needs to check _options.ConnectionSettings.ServerVersion.SupportsRenameIndex and use it if available, otherwise fallback to drop and re-create.


Happy to accept it as a PR or we can fix it.

On a side note it'd be good to add MySql 5.6 and MariDB 10.3 to our TravisCI setup to catch stuff like this

@caleblloyd caleblloyd added this to the 2.0.0 milestone Jul 12, 2017
@nover
Copy link
Contributor Author

nover commented Jul 12, 2017

@caleblloyd thanks for clarifying, I'll try to look into it tomorrow if I get the time.
I also created an issue with MariaDB to see if we can get RENAME INDEX support added there.
https://jira.mariadb.org/browse/MDEV-13301

@nover
Copy link
Contributor Author

nover commented Jul 13, 2017

@caleblloyd I see that you tagged it up for the 2.0 release - would it be possible to backport it to the 1.1 series? Because we kind of need the feature for a project running on 1.1 that can't be upgraded to the preview.

@yukozh
Copy link
Member

yukozh commented Jul 13, 2017

@nover Sorry, we don't have an LTS plan for 1.1, maintaining different versions is a huge program, and we only have 2 people maintaining this project. Besides, for this issue, it was just an enhancement, not a bug.

@nover
Copy link
Contributor Author

nover commented Jul 13, 2017

@kagamine Fair enough - what if I make two PRs? One based off master for 2.0 and one based off the 1.1.2-rtm branch?

@yukozh
Copy link
Member

yukozh commented Jul 13, 2017

should push to 1.1.3 branch

@caleblloyd
Copy link
Contributor

Sure we'll accept a PR and push a 1.1.3 prerelease for you!

@nover
Copy link
Contributor Author

nover commented Jul 13, 2017

Okay PR ready for version 2.0:
#321

@nover
Copy link
Contributor Author

nover commented Jul 13, 2017

Backport of changes for 1.1:
#322

@yukozh yukozh closed this as completed Jul 29, 2017
@savissimo
Copy link

Excuse me, I have the issue with RENAME INDEX, and apparently this fix would solve that. But I can't understand how I should use it. Thanks for any help!

@mc0re
Copy link

mc0re commented May 14, 2020

My version string on the server is:

$ mysql -V
mysql  Ver 15.1 Distrib 10.4.12-MariaDB, for Linux (x86_64) using readline 5.1

But the index renaming is still not supported:

 MySql.Data.MySqlClient.MySqlException (0x80004005): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to u
se near 'INDEX `IX_CourseFiles_Hash` TO `IX_Files_Hash`' at line 1

Can I force the server version somehow?

@mguinness
Copy link
Collaborator

See ServerVersion in Configuration Options wiki.

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

No branches or pull requests

6 participants