- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 394
Description
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.
Activity
yukozh commentedon 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 commentedon Jul 12, 2017
Okay, so the driver basically supports MYSQL 5.7, with no intention to support older versions of MYSQL nor mariadb?
caleblloyd commentedon Jul 12, 2017
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
nover commentedon 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 commentedon 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 commentedon 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 commentedon 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 commentedon Jul 13, 2017
should push to 1.1.3 branch
caleblloyd commentedon Jul 13, 2017
Sure we'll accept a PR and push a 1.1.3 prerelease for you!
nover commentedon Jul 13, 2017
Okay PR ready for version 2.0:
#321
nover commentedon Jul 13, 2017
Backport of changes for 1.1:
#322
savissimo commentedon Mar 6, 2019
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 commentedon May 14, 2020
My version string on the server is:
But the index renaming is still not supported:
Can I force the server version somehow?
mguinness commentedon May 15, 2020
See ServerVersion in Configuration Options wiki.