drizzle-team / drizzle-kit-mirror

Docs and issues repository for drizzle-kit
288 stars 16 forks source link

Corrupted schema data generated by `introspect` #427

Open serhii-kucherenko opened 1 month ago

serhii-kucherenko commented 1 month ago

I generated schema from the existing supabase and got a lot of unknown functions that I assume should be different or at least auto-imported from zod (for example). It's a HUGE blocker to proceed with the drizzle further for my project. Let me know if you can help me. Thanks.

Schreenshots

  1. Table from supabase schema: "auth"
  2. Table from supabase schema: "public"

image image

Dependencies

"drizzle-kit": "0.21.3",
"drizzle-orm": "0.30.10",
"drizzle-zod": "0.5.1",
"ts-node": "10.9.2",
"typescript": "5.4.5"
AlexBlokh commented 1 month ago

can you please share a pg dump without data?

serhii-kucherenko commented 1 month ago

can you please share a pg dump without data?

@AlexBlokh can I email it to you? Don't want to share it here

PawelDmochowskiMeetingPackage commented 4 weeks ago

Providing more context because this is not supabase specific. In my case it's PostgreSQL. A simple repro:

Those DDL statements

CREATE SEQUENCE IF NOT EXISTS public.test_table_id_seq
    INCREMENT 1
    START 1
    MINVALUE 1
    MAXVALUE 9223372036854775807
    CACHE 1;

CREATE TABLE test_table
(
    id bigint NOT NULL DEFAULT nextval('test_table_id_seq'::regclass),
    case_insensitive_name citext,
    price money
);

are introspected to

export const testTable = pgTable("test_table", {
    // You can use { mode: "bigint" } if numbers are exceeding js number limitations
    id: bigint("id", { mode: "number" }).default(nextval('test_table_id_seq'::regclass)).notNull(),
    // TODO: failed to parse database type 'citext'
    caseInsensitiveName: unknown("case_insensitive_name"),
    // TODO: failed to parse database type 'money'
    price: unknown("price"),
});

It's clear that default value for id column should be sql-quoted and citext and money types are "unknown".

citext is from extension so that's kind of understandable. money though is a built-in type for PostgreSQL.

My env:

"drizzle-kit": "0.22.1",
"drizzle-orm": "0.31.0",
"ts-node": "10.9.2",
"typescript": "5.4.5"
tehnorm commented 2 weeks ago

Looks like this might be the same issue https://github.com/drizzle-team/drizzle-kit-mirror/issues/441 nextval is not getting wrapped correctly with sql