oguimbal / pg-mem

An in memory postgres DB instance for your unit tests

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support add primary key

ranmocy opened this issue Β· comments

commented

Describe the bug

I'm trying to alter table's primary key, but it fails even the primary key constraint was dropped before.

Table user already has a primary key

🐜 This seems to be an execution error, which means that your request syntax seems okay,
    but the resulting statement cannot be executed β†’ Probably not a pg-mem error.

*️⃣ Reconsituted failed SQL statement: ALTER TABLE "user"  DROP CONSTRAINT user_pkey,  ADD primary key(name)

πŸ‘‰ You can file an issue at https://github.com/oguimbal/pg-mem along with a way to reproduce this error (if you can), and  the stacktrace:

To Reproduce

Reproducible with pg-mem playground: https://oguimbal.github.io/pg-mem-playground/

CREATE TABLE "user" ("id" SERIAL NOT NULL, "name" text NOT NULL, CONSTRAINT "user_pkey" PRIMARY KEY ("id"));
ALTER TABLE "user" DROP CONSTRAINT "user_pkey", ADD PRIMARY KEY(name);  # <= Error on this line

pg-mem version

2.6.3