Dr. Pure
Dr. Pure
Explore posts from servers
DTDrizzle Team
Created by Dr. Pure on 7/14/2024 in #help
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
$ 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
21 replies
DTDrizzle Team
Created by Dr. Pure on 7/13/2024 in #help
bit type goes to postgresql as a string
Hello! I was recently creating my schemas for a project (I am using postgresql) and I set a column as bit(10), but drizzle-kit push passes it to postgresql as a string so that postgresql gives an error.
export const users = pgTable(
"user",
{
id: bigint("id", { mode: "bigint" }).primaryKey(),
test: bit("test", { dimensions: 10 }),
}
);
export const users = pgTable(
"user",
{
id: bigint("id", { mode: "bigint" }).primaryKey(),
test: bit("test", { dimensions: 10 }),
}
);
->
CREATE TABLE IF NOT EXISTS "formatting" (
"id" bigint PRIMARY KEY NOT NULL,
"test" "bit(10)",
);
CREATE TABLE IF NOT EXISTS "formatting" (
"id" bigint PRIMARY KEY NOT NULL,
"test" "bit(10)",
);
ERROR: type "bit(10)" does not exist at character 161
11 replies