Invalid Postgresql drop foreign key

TheColorRed's profile image TheColorRed posted 4 years ago in General Permalink

When dropping a key in the "Foreign keys" tab, the command that is executed is this:

ALTER TABLE "example" DROP FOREIGN KEY "FK_key";

This throws an error:

ERROR: syntax error at or near "FOREIGN" LINE 2: DROP FOREIGN KEY "FK_key"

The proper syntax is (at least one that works) uses DROP CONSTRAINT instead of DROP FOREIGN KEY:

ALTER TABLE "example" DROP CONSTRAINT "FK_key";

PostgreSQL version:

$ SELECT VERSION()
PostgreSQL 12.4 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.3 20140911 (Red Hat 4.8.3-9), 64-bit
ansgar's profile image ansgar posted 4 years ago Permalink

That is quite helpful. Could you please report that in the Github tracker? See menu "Bugtracker" > "Bug reports"

Please login to leave a reply, or register at first.