vapor / fluent-kit

Swift ORM (queries, models, and relations) for NoSQL and SQL databases
MIT License
217 stars 116 forks source link

Fully work around MySQL 5.7's lack of the DROP CONSTRAINT statement #575

Closed gwynne closed 1 year ago

gwynne commented 1 year ago

The work done in vapor/fluent-kit#522 added the ability to drop foreign keys when using a MySQL 5.7 database by enabling Fluent to generate the necessary DROP FOREIGN KEY syntax to make up for the old version's lack of the more standard and more flexible DROP CONSTRAINT statement.

However, this still required users to specify the complete and current foreign key constraint definition at the time of deletion so Fluent could work out the correct "normalized" constraint identifier. These changes make it possible to also drop a foreign key constraint by name, requiring only the knowledge that it is, in fact, a foreign key.

Users wishing to drop foreign key constraints by name when using MySQL 5.7 must use the new API provided. Users of other versions of MySQL and other databases may also use the new API, or continue to use the old one.

New APIs added in this release:

Fixes #491, vapor/fluent#722. Supersedes #492, #522.

codecov-commenter commented 1 year ago

Codecov Report

Merging #575 (3df79a9) into main (9c0ec57) will decrease coverage by 0.03%. The diff coverage is 0.00%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #575 +/- ## ========================================== - Coverage 47.63% 47.61% -0.03% ========================================== Files 106 106 Lines 4702 4704 +2 ========================================== Hits 2240 2240 - Misses 2462 2464 +2 ``` | [Files Changed](https://app.codecov.io/gh/vapor/fluent-kit/pull/575?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor) | Coverage Δ | | |---|---|---| | [Sources/FluentKit/Schema/DatabaseSchema.swift](https://app.codecov.io/gh/vapor/fluent-kit/pull/575?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor#diff-U291cmNlcy9GbHVlbnRLaXQvU2NoZW1hL0RhdGFiYXNlU2NoZW1hLnN3aWZ0) | `54.54% <0.00%> (-3.52%)` | :arrow_down: | | [Sources/FluentKit/Schema/SchemaBuilder.swift](https://app.codecov.io/gh/vapor/fluent-kit/pull/575?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor#diff-U291cmNlcy9GbHVlbnRLaXQvU2NoZW1hL1NjaGVtYUJ1aWxkZXIuc3dpZnQ=) | `70.93% <0.00%> (+1.61%)` | :arrow_up: | | [Sources/FluentSQL/SQLSchemaConverter.swift](https://app.codecov.io/gh/vapor/fluent-kit/pull/575?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor#diff-U291cmNlcy9GbHVlbnRTUUwvU1FMU2NoZW1hQ29udmVydGVyLnN3aWZ0) | `64.01% <0.00%> (-0.55%)` | :arrow_down: |