MakoBuk
MakoBuk

Reputation: 474

Postgres - remove unique contraint (does not exist)

I have following table:

enter image description here

I have created unique constraint CREATE UNIQUE INDEX unique_item_media_idx ON mediagalleryitem (article_id, media_id);

Now, I want to remove it and it is impossible for me. When I execute ALTER TABLE "mediagalleryitem" DROP CONSTRAINT unique_item_media_idx; it tells me: constraint "unique_item_media_idx" of relation "mediagalleryitem" does not exist

When I run from CLI \d mediagalleryitem I get:

Indexes:
"mediagalleryitem_pkey" PRIMARY KEY, btree (id)
"unique_item_media_idx" UNIQUE, btree (article_id, media_id)
"idx_1c5848117294869c" btree (article_id)
"idx_1c584811ea9fdd75" btree (media_id)

Foreign-key constraints:
"fk_1c5848117294869c" FOREIGN KEY (article_id) REFERENCES article(id)
"fk_1c584811ea9fdd75" FOREIGN KEY (media_id) REFERENCES media(id)

Whwere is the problem?

Upvotes: 1

Views: 4338

Answers (1)

Sami Kuhmonen
Sami Kuhmonen

Reputation: 31213

What you have there is an index, not a constraint. You can drop it using DROP INDEX unique_item_media_idx. Just as you created an index, you remove an index.

Upvotes: 3

Related Questions