© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•14mo ago•
1 reply
michi

[solved] drizzle-kit push fails when using with cockroachdb

I have simply used
pnpx sv create .
pnpx sv create .
and then pasted in my connection string from cockroachdb to my
.env
.env
and am trying to run
drizzle-kit push
drizzle-kit push
as instructed.
> drizzle-kit push

drizzle-kit: v0.22.8
drizzle-orm: v0.33.0

No config path provided, using default path
Reading config file '/home/keogami/code/suchajoy/drizzle.config.ts'
Using 'postgres' driver for database querying
[✓] Pulling schema from database...

 Warning  You are about to execute current statements:

CREATE TABLE IF NOT EXISTS "session" (
        "id" text PRIMARY KEY NOT NULL,
        "user_id" text NOT NULL,
        "expires_at" timestamp with time zone NOT NULL
);

CREATE TABLE IF NOT EXISTS "user" (
        "id" text PRIMARY KEY NOT NULL,
        "age" integer
);

DO $$ BEGIN
 ALTER TABLE "session" ADD CONSTRAINT "session_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
 WHEN duplicate_object THEN null;
END $$;


PostgresError: at or near "do": syntax error
    at ErrorResponse (/home/keogami/code/suchajoy/node_modules/.pnpm/drizzle-kit@0.22.8/node_modules/drizzle-kit/bin.cjs:79677:27)
    at handle (/home/keogami/code/suchajoy/node_modules/.pnpm/drizzle-kit@0.22.8/node_modules/drizzle-kit/bin.cjs:79454:7)
    at TLSSocket.data (/home/keogami/code/suchajoy/node_modules/.pnpm/drizzle-kit@0.22.8/node_modules/drizzle-kit/bin.cjs:79277:9)
    at TLSSocket.emit (node:events:513: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 TLSWrap.onStreamRead (node:internal/stream_base_commons:189:23)
    at TLSWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
  severity_local: 'ERROR',
  severity: 'ERROR',
  code: '42601',
  detail: 'source SQL:\nDO $$ BEGIN\n^',
  file: 'lexer.go',
  line: '399',
  routine: 'Error'
}
> drizzle-kit push

drizzle-kit: v0.22.8
drizzle-orm: v0.33.0

No config path provided, using default path
Reading config file '/home/keogami/code/suchajoy/drizzle.config.ts'
Using 'postgres' driver for database querying
[✓] Pulling schema from database...

 Warning  You are about to execute current statements:

CREATE TABLE IF NOT EXISTS "session" (
        "id" text PRIMARY KEY NOT NULL,
        "user_id" text NOT NULL,
        "expires_at" timestamp with time zone NOT NULL
);

CREATE TABLE IF NOT EXISTS "user" (
        "id" text PRIMARY KEY NOT NULL,
        "age" integer
);

DO $$ BEGIN
 ALTER TABLE "session" ADD CONSTRAINT "session_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
 WHEN duplicate_object THEN null;
END $$;


PostgresError: at or near "do": syntax error
    at ErrorResponse (/home/keogami/code/suchajoy/node_modules/.pnpm/drizzle-kit@0.22.8/node_modules/drizzle-kit/bin.cjs:79677:27)
    at handle (/home/keogami/code/suchajoy/node_modules/.pnpm/drizzle-kit@0.22.8/node_modules/drizzle-kit/bin.cjs:79454:7)
    at TLSSocket.data (/home/keogami/code/suchajoy/node_modules/.pnpm/drizzle-kit@0.22.8/node_modules/drizzle-kit/bin.cjs:79277:9)
    at TLSSocket.emit (node:events:513: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 TLSWrap.onStreamRead (node:internal/stream_base_commons:189:23)
    at TLSWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
  severity_local: 'ERROR',
  severity: 'ERROR',
  code: '42601',
  detail: 'source SQL:\nDO $$ BEGIN\n^',
  file: 'lexer.go',
  line: '399',
  routine: 'Error'
}
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 fails with neon
Drizzle TeamDTDrizzle Team / help
12mo ago
drizzle-kit push
Drizzle TeamDTDrizzle Team / help
5mo ago
drizzle-kit push fails every second time
Drizzle TeamDTDrizzle Team / help
2y ago
Error with drizzle-kit push
Drizzle TeamDTDrizzle Team / help
16mo ago