Issue with constraint primary key when using drizzle-kit push 2 times.

Hello! I am facing an issue where if I use
drizzle-kit push
2 times without making any changes on a schema with a table with a constraint primary key.

First push. Works as intended.
$ drizzle-kit push
drizzle-kit: v0.23.0
drizzle-orm: v0.32.0

No config path provided, using default path
Reading config file '/home/pure/drizzle-test/drizzle.config.ts'
Using 'postgres' driver for database querying
[✓] Pulling schema from database...
[✓] Changes applied
Done in 0.30s.
pure@Pure:~/drizzle-test$ yarn db:push
yarn run v1.22.22

Second push. Gives an error.
$ drizzle-kit push
drizzle-kit: v0.23.0
drizzle-orm: v0.32.0

No config path provided, using default path
Reading config file '/home/pure/drizzle-test/drizzle.config.ts'
Using 'postgres' driver for database querying
[✓] Pulling schema from database...
PostgresError: column "user_id" is in a primary key
    at ErrorResponse (/home/pure/drizzle-test/node_modules/drizzle-kit/bin.cjs:81460:27)
    at handle (/home/pure/drizzle-test/node_modules/drizzle-kit/bin.cjs:81237:7)
    at Socket.data (/home/pure/drizzle-test/node_modules/drizzle-kit/bin.cjs:81060:9)
    at Socket.emit (node:events:518:28)
    at addChunk (node:internal/streams/readable:559:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
    at Readable.push (node:internal/streams/readable:390:5)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
    at TCP.callbackTrampoline (node:internal/async_hooks:130:17) {
  severity_local: 'ERROR',
  severity: 'ERROR',
  code: '42P16',
  file: 'tablecmds.c',
  line: '7398',
  routine: 'ATExecDropNotNull'
}
Done in 0.31s.


Ran sql command when pushing the second time:
STATEMENT:  ALTER TABLE "test_table" ALTER COLUMN "user_id" DROP NOT NULL;


A reproduction can be tried cloning this repository (the problem doesn't appear in https://drizzle.run). https://github.com/PureSci/drizzle-push-issue
GitHub
Contribute to PureSci/drizzle-push-issue development by creating an account on GitHub.
Was this page helpful?