Is there a way to configure pg introspect to generate date rather than string inference columns?

My workflow involves writing migrations by hand outside of drizzle and using schema introspection to pull in changes. This works well except for date columns, which are always generated as mode: 'string' by default.
9 Replies
Mykhailo
Mykhailo11mo ago
Hello, @francis! It is impossible to configure pg introspect in your workflow to generate date columns with a specific mode other than the default string mode. Because mode option is not directly related to SQL but is a feature specific to Drizzle, which operates at the TypeScript level. If you need to set a different mode, this adjustment has to be done manually. In your schema, you would specify it as date: date('date', { mode: "date" }),
francis
francis11mo ago
that's unfortunate. this adjustment would be overwritten every time we pull, correct? we are using supabase with extensions and using the supabase migration system to deploy them. I suppose we could use drizzle to generate migrations and then modify the generated sql by hand to add row level security commands, etc?
Angelelz
Angelelz11mo ago
Do you work on a linux or mac? How do you run the introspect?
francis
francis11mo ago
I could use a postprocess step to convert them, yeah, but that's a code/process smell to me I think the actual solution here is to embrace drizzle, generate migrations with drizzle, then edit them to add supabase extra stuff when ready to deploy so I'm not pulling with introspect on every single schema change
Angelelz
Angelelz11mo ago
I'd suggest you add a line to your scripts in package.json:
{
"instrospect": "drizzle-kit introspect:pg && sed -i 's/{ mode: "date" }/{ mode: "string" }/g' <your_schems_file.ts>"
}
{
"instrospect": "drizzle-kit introspect:pg && sed -i 's/{ mode: "date" }/{ mode: "string" }/g' <your_schems_file.ts>"
}
francis
francis11mo ago
yeeeeeeah I was thinking of that. but I'd rather not
Angelelz
Angelelz11mo ago
Might need some adjustoments
francis
francis11mo ago
I should probably just update my workflow. thanks!
Angelelz
Angelelz11mo ago
It's just workarounds, you might want to submit a feature request in GH I was working on getting RLS in drizzle, so that's a plus I should finish that pr this weekend
Want results from more Discord servers?
Add your server