drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
22.99k stars 550 forks source link

[BUG]: Introspect migration has unterminated comment #2126

Open jansedlon opened 5 months ago

jansedlon commented 5 months ago

What version of drizzle-orm are you using?

0.30.7

What version of drizzle-kit are you using?

0.20.14

Describe the Bug

  1. Have an existing Prisma DB
  2. Create drizzle config
  3. Run drizzle-kit introspect:pg
  4. Run the generated migration

It throws

error: unterminated /* comment at or near "/*
DO $$ BEGIN
 CREATE TYPE "UserRole" AS ENUM('ADMIN', 'USER');
EXCEPTION
 WHEN duplicate_object THEN null;
END $$;
"
error: unterminated /* comment at or near "/*
DO $$ BEGIN
 CREATE TYPE "UserRole" AS ENUM('ADMIN', 'USER');
EXCEPTION
 WHEN duplicate_object THEN null;
END $$;
"

Expected behavior

It shouldn't do anything since the whole migration is commented

The initial migration looks like this

-- Current sql file was generated after introspecting the database
-- If you want to run this migration please uncomment this code before executing migrations
/*
DO $$ BEGIN
 CREATE TYPE "UserRole" AS ENUM('ADMIN', 'USER');
EXCEPTION
 WHEN duplicate_object THEN null;
END $$;

-- Rest of the migration
-- ...

Environment & setup

No response

jansedlon commented 5 months ago

Reading the comment in the initial migration again.. I'm not sure if it means that commenting this is optional is I most likely have an already setup database and this migrations shouldn't run or the comment syntax is wrong on purpose and I should specifically remove the comment :D

But seems like the C like syntax is supported

ovistoica commented 2 months ago

I have the same bug and I can't finish the migration from prisma

jpgcarvalho commented 4 weeks ago

I'm facing the same error. What can i do to solve that problem?