Skip to content

[5.7] Throw on trying to drop foreign keys in SQLite #24052

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

Merged
merged 2 commits into from
Apr 29, 2018

Conversation

JanisE
Copy link
Contributor

@JanisE JanisE commented Apr 29, 2018

SQLite doesn't support dropping foreign keys (you would need to re-create the table).

See #24041

@GrahamCampbell GrahamCampbell changed the title Throw on trying to drop foreign keys in SQLite [5.6] Throw on trying to drop foreign keys in SQLite Apr 29, 2018
@GrahamCampbell GrahamCampbell changed the title [5.6] Throw on trying to drop foreign keys in SQLite [5.7] Throw on trying to drop foreign keys in SQLite Apr 29, 2018
);
}

if ($this->commandsNamed(['dropForeign'])->count() > 1) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be > 0 surely?

@JanisE
Copy link
Contributor Author

JanisE commented Apr 29, 2018

Yes, sorry. In my test sample, I had several dropForeign requests, that's why it worked for me...

@mchekin
Copy link

mchekin commented Nov 25, 2019

@JanisE
@GrahamCampbell

Excuse me for my curiosity, but ...

Why not just fix the implementation, instead of throwing the exception?

As mentioned by @staudenmeir
#24041 (comment)

There is a proper way to drop foreign key in SQLite by recreating the table:
https://www.techonthenet.com/sqlite/foreign_keys/drop.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants