© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•2y ago•
20 replies
Pure

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
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
$ 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.
$ 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;
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
GitHub - PureSci/drizzle-push-issue
Contribute to PureSci/drizzle-push-issue development by creating an account on GitHub.
GitHub - PureSci/drizzle-push-issue
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

drizzle-kit push error: Multiple primary key defined
Drizzle TeamDTDrizzle Team / help
2y ago
Drizzle-kit Multiple primary key defined issue
Drizzle TeamDTDrizzle Team / help
2y ago
drizzle push and primary key order
Drizzle TeamDTDrizzle Team / help
3y ago
[solved] drizzle-kit push fails when using with cockroachdb
Drizzle TeamDTDrizzle Team / help
14mo ago