Skip to content

Issue with migrations on MariaDB 10.2 #320

@nover

Description

@nover
Contributor

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

yukozh commented on Jul 12, 2017

@yukozh
Member

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

nover

nover commented on Jul 12, 2017

@nover
ContributorAuthor

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

caleblloyd

caleblloyd commented on Jul 12, 2017

@caleblloyd
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

added this to the 2.0.0 milestone on Jul 12, 2017
nover

nover commented on Jul 12, 2017

@nover
ContributorAuthor

@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

nover commented on Jul 13, 2017

@nover
ContributorAuthor

@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

yukozh commented on Jul 13, 2017

@yukozh
Member

@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

nover commented on Jul 13, 2017

@nover
ContributorAuthor

@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

yukozh commented on Jul 13, 2017

@yukozh
Member

should push to 1.1.3 branch

caleblloyd

caleblloyd commented on Jul 13, 2017

@caleblloyd
Contributor

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

nover

nover commented on Jul 13, 2017

@nover
ContributorAuthor

Okay PR ready for version 2.0:
#321

nover

nover commented on Jul 13, 2017

@nover
ContributorAuthor

Backport of changes for 1.1:
#322

savissimo

savissimo commented on Mar 6, 2019

@savissimo

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

mc0re commented on May 14, 2020

@mc0re

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

mguinness commented on May 15, 2020

@mguinness
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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @nover@yukozh@caleblloyd@savissimo@mc0re

        Issue actions

          Issue with migrations on MariaDB 10.2 · Issue #320 · PomeloFoundation/Pomelo.EntityFrameworkCore.MySql