dolthub / dolthub/dolt

Can't drop primary key in table with foreign key constraint on other column

Open
#10,328 1 comment 0 reactions 0 assignees View on GitHub
bug correctness
Dominant language
Go
Stars
24.4k
Forks
873
Avg merge
1d 5h
Merged PRs (30d)
108

Description

Dolt version 1.80.2

Repro:

Foreign key checks **must be off**

```
% dolt init
Successfully initialized dolt data repository.
% dolt sql
test/main> CREATE TABLE test1 (id int primary key);
Query OK, 0 rows affected (0.01 sec)
test/main*> CREATE TABLE test2 (id INT PRIMARY KEY, ref INT, CONSTRAINT fk FOREIGN KEY (ref) REFERENCES test1(id));
Query OK, 0 rows affected (0.01 sec)
test/main*> ALTER TABLE test2 DROP PRIMARY KEY;
error: can't drop index 'PRIMARY': needed in foreign key constraint fk
```

Works in mysql.

You can drop primary keys of the same table if it doesn't have the foreign key constraint.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.