mysql2sqlite icon indicating copy to clipboard operation
mysql2sqlite copied to clipboard

default foreign key behavior

Open stingray-11 opened this issue 3 years ago • 3 comments

In MySQL the default foreign key ON DELETE behavior is RESTRICT, in SQLite it's NO ACTION. I think it would make sense if this script would automatically add "ON DELETE RESTRICT" to the end of foreign keys in MySQL that don't specify the ON DELETE, so that the default behavior matches.

In my MySQL database I specifically have the foreign keys set to ON DELETE RESTRICT and yet in the resulting mysqldump they are not specified, so it's not a case of just having them set to the defaults.

stingray-11 avatar Jan 09 '22 20:01 stingray-11

Sounds good to me. I'm very busy unfortunately (see all the PRs waiting for thorough review - would you help with that?), so if you want this to happen, please make a PR.

And if you want it merged soon, please review several other PRs and I'll try my best to find the time to review yours :wink: (or you can find another person to review your PR).

dumblob avatar Jan 10 '22 18:01 dumblob

Unfortunately I am not at all familiar with awk scripting but if I get a chance I will certainly give it a try.

stingray-11 avatar Jan 11 '22 02:01 stingray-11

Note that this is still a bug, but not as big of a deal as I originally thought. NO ACTION in SQLite just means the check is deferred until the end of the transaction, not that it doesn't happen at all. In MySQL both NO ACTION and RESTRICT do the check immediately.

stingray-11 avatar Mar 20 '22 19:03 stingray-11