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

Auto-generated FK names don't match MySQL for renamed tables #7959

Closed
arvidfm opened this issue Jun 5, 2024 · 3 comments
Closed

Auto-generated FK names don't match MySQL for renamed tables #7959

arvidfm opened this issue Jun 5, 2024 · 3 comments
Labels
correctness We don't return the same result as MySQL customer issue enhancement New feature or request

Comments

@arvidfm
Copy link

arvidfm commented Jun 5, 2024

In MySQL, if you rename a table, any autogenerated foreign keys will be renamed as well to match the new table name. This is not the case with Dolt, making it harder to write migrations operating on previously renamed tables that work with both MySQL and Dolt.

MWE, works with Percona Server 8.3, but fails with Dolt at DROP FOREIGN KEY because the FK is still named b_test_ibfk_1 instead of c_test_ibfk_1.

DROP TABLE IF EXISTS c_test, b_test, a_test;

CREATE TABLE a_test (id INT PRIMARY KEY);

CREATE TABLE b_test(
    a_id INT,
    FOREIGN KEY (a_id) REFERENCES a_test (id)
);

RENAME TABLE b_test TO c_test;

ALTER TABLE c_test DROP FOREIGN KEY c_test_ibfk_1;

DROP TABLE IF EXISTS c_test, b_test, a_test;
@timsehn timsehn added enhancement New feature or request correctness We don't return the same result as MySQL labels Jun 6, 2024
@fulghum
Copy link
Contributor

fulghum commented Jun 6, 2024

Thanks for reporting this difference with MySQL's behavior. I'm starting to dig into this one now.

@fulghum
Copy link
Contributor

fulghum commented Jun 6, 2024

@arvidfm – the fix for this one is merged into Dolt now, and will go out in our next release. We'll try to get a few more fixes checked in for you and run a release later tonight or tomorrow.

@fulghum
Copy link
Contributor

fulghum commented Jun 8, 2024

@arvidfm – The fix for this issue has been released in Dolt 1.39.4. Thanks again for pointing out this behavior difference so we could fix it! 🙏 Let us know if you find anything else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
correctness We don't return the same result as MySQL customer issue enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants