Can't delete indexes that constraints depend on
- Dominant language
- Python
- Stars
- 485
- Forks
- 8
- PR merge metrics
- No merged PRs in 30d
Description
Consider this DDL:
DROP TABLE IF EXISTS my_table;
CREATE TABLE my_table
( id serial
, title varchar(100)
, isbn varchar(13) NOT NULL
, copy_nr integer NOT NULL
, PRIMARY KEY (id)
, UNIQUE (isbn, copy_nr)
);
To reproduce:
* run this SQL to create the table
* reload (cmd+R)
* select `my_table`, choose `Structure`
* press the minus (`-`) button right of the index-definition
* press save changes
expected:
* The index will be dropped.
actual:
* I get an error, the index can't be dropped because there is still a constraint (`PostgreSQL said: cannot drop index my_table_pkey because constraint my_table_pkey on table my_table requires it
Hint: You can drop constraint my_table_pkey on table my_table instead.`). See

The same goes for the composite-index.
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the SQL setup, then use the Structure view on my_table and follow the index deletion through Save Changes. Check how primary-key and composite unique constraints are represented when their indexes are removed; done means the operation succeeds by handling the dependent constraint instead of issuing an invalid index drop.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, python
- Domain
- database, desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100