-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Sqlite: what is needed to re-introduce foreign key constraint support? #4288
Comments
Hello, Have you tried with this event ? To enable it: services:
my.listener:
class: App\Doctrine\SqliteForeignKeyEnabler
autowire: true
tags:
- { name: doctrine.event_listener, event: preFlush } |
No, I wasn't aware that I could do that. I'll find that a go when I have the time! |
Just FYI, I tested locally with and without this and it seems that foreign key support is supported on my laptop. I'm using SQLite 3.31.1 |
Excellent, that's really good to know. |
looks like this does not work anymore with recent version of dbal (3.3.5), i can see that the event gets fired and the statement executed in logs but schema diff still does not correctly recognize foreign keys |
Same for me - seems obvious that no command executed on the connection can change this behaviour as Some ideas:
|
See #5427. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Feature Request
Foreign key constraint support is missing for sqlite. I would like to understand what can be done to allow
SqlitePlatform::supportsForeignKeyConstraints()
to returntrue
.Without such support, I find that when an entity has a property that is a foreign key, the creation of a new migration always creates a migration to drop and re-create that table and a fk-related index which is unnecessary.
Summary
I'd like
Doctrine\DBAL\Platforms\SqlitePlatform::supportsForeignKeyConstraints()
to returntrue
. I fully appreciate that merely changing the currentreturn false
toreturn true
is by no means all that is needed.Support was added in commit 85a983c3f8d6447c4441832477def1c28d57bee9 and that change was reverted before too long in commit baec4b8ea8aabe7b9c58b403d706465c897f4be9 due to matters presented in issue #4243.
My rough understanding of #4243 is that commit 85a983c3f8d6447c4441832477def1c28d57bee9 introduced a BC change which was undesirable for a minor release.
I can't quite tell if the same BC change would be acceptable for a major release or whether the same change can be introduced in a way that is not a breaking, or possibly some third option.
At present if using sqlite and when dealing with entities that make use of foreign keys (such as via a
@ORM\ManyToOne
annotation) my only options seem to be:For now I'll switch to postgres but would love to come back to using sqlite in the future.
The text was updated successfully, but these errors were encountered: