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

Deprecate ignoring foreign keys DDL on non-InnoDB MySQL #5414

Merged
merged 1 commit into from
May 27, 2022

Conversation

morozov
Copy link
Member

@morozov morozov commented May 27, 2022

I'm working on replacing CreateSchemaSqlCollector and DropSchemaSqlCollector with another set of SQL builders to enable seamless support for foreign keys on SQLite (see #5409 (comment)).

There will be a new platform method that will generate SQL to create a set of tables that may reference each other via foreign keys at once.

The default implementation in the AbstractPlatform class will first create all tables without foreign keys and then create all foreign keys. This way, the foreign key dependencies will be satisfied at every step of the migration.

The implementation for the SQLite platform will just create the tables with the foreign keys because:

  1. SQLite doesn't support adding foreign keys to an existing table.
  2. SQLite doesn't require the table referenced by a foreign key to exist when the table is created.

In order to support the feature being deprecated, I'll have to create another implementation of the above method for MySQL which would ignore foreign keys in the new method if the target engine will ignore them.

While it's not a big deal, I believe this functionality is pointless: if the application that owns the schema doesn't require the support for foreign keys across all target platforms and storage engines, it should enforce referential integrity itself, at which point it won't require it enforced by the database platform. If it does need them, it should use only the platforms and the engines that support them.

@morozov morozov merged commit 568a34d into doctrine:3.4.x May 27, 2022
@morozov morozov deleted the deprecate-innodb-only-fk branch May 27, 2022 14:25
@morozov morozov added this to the 3.4.0 milestone Jun 3, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants