Re: [GENERAL] DROP INDEX CASCADE doesn't want to drop uniqueconstraints? - Mailing list pgsql-general

From Andreas Kretschmer
Subject Re: [GENERAL] DROP INDEX CASCADE doesn't want to drop uniqueconstraints?
Date
Msg-id 20170424123814.GA20971@tux
Whole thread Raw
In response to [GENERAL] DROP INDEX CASCADE doesn't want to drop unique constraints?  (Ivan Voras <ivoras@gmail.com>)
List pgsql-general
Ivan Voras <ivoras@gmail.com> wrote:

> Hello,
>
> On trying to drop an index named "employer_employerid_key" which supports a
> unique constraint:
>
>     "employer_employerid_key" UNIQUE CONSTRAINT, btree (employerid)
>
> I get this error:
>
> ERROR:  cannot drop index employer_employerid_key because constraint
> employer_employerid_key on table employer requires it
> HINT:  You can drop constraint employer_employerid_key on table employer
> instead.
>
> I'm using the CASCADE and IF EXISTS arguments and the docs say nothing about
> any special cases (https://www.postgresql.org/docs/9.3/static/
> sql-dropindex.html). This is with PostgreSQL 9.3.15. 
>
> The actual command is:
>
> drop index if exists employer_employerid_key cascade;
>
> Any ideas if this is normal or why it happens?


Drop the constraint:

alter table employer drop constraint employer_employerid_key;





Regards, Andreas Kretschmer
--
Andreas Kretschmer
http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


pgsql-general by date:

Previous
From: Ivan Voras
Date:
Subject: [GENERAL] DROP INDEX CASCADE doesn't want to drop unique constraints?
Next
From: Adrian Klaver
Date:
Subject: Re: [GENERAL] [pgadmin-hackers] file permission on ssl key