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 pushdrizzle-kit: v0.23.0drizzle-orm: v0.32.0No config path provided, using default pathReading config file '/home/pure/drizzle-test/drizzle.config.ts'Using 'postgres' driver for database querying[✓] Pulling schema from database...[✓] Changes appliedDone in 0.30s.pure@Pure:~/drizzle-test$ yarn db:pushyarn run v1.22.22
$ drizzle-kit pushdrizzle-kit: v0.23.0drizzle-orm: v0.32.0No config path provided, using default pathReading config file '/home/pure/drizzle-test/drizzle.config.ts'Using 'postgres' driver for database querying[✓] Pulling schema from database...[✓] Changes appliedDone in 0.30s.pure@Pure:~/drizzle-test$ yarn db:pushyarn run v1.22.22
Second push. Gives an error.
$ drizzle-kit pushdrizzle-kit: v0.23.0drizzle-orm: v0.32.0No config path provided, using default pathReading 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 pushdrizzle-kit: v0.23.0drizzle-orm: v0.32.0No config path provided, using default pathReading 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;