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
24.31k stars 627 forks source link

[BUG]: 'type "geography(Point)" does not exist' when using push:pg #1315

Open taeling opened 1 year ago

taeling commented 1 year ago

What version of drizzle-orm are you using?

0.28.6

What version of drizzle-kit are you using?

0.19.13

Describe the Bug

drizzle-kit push:pg does not complete when using a custom type and trying to push the schema to a postgres with postgis installed (using docker); it stops with the following error:

error: type "geography(Point)" does not exist

I've created a minimal reproduction:

https://codesandbox.io/p/sandbox/wandering-brook-vwwtj2

Expected behavior

The push command should complete without error. I can manually alter the table and add a column with the geography(Point) data type, so the database setup seems to be ok.

Environment & setup

Locally (Fedora) and on codesandbox

DNoel26 commented 10 months ago

I'm experiencing this same issue

madebyfabian commented 9 months ago

Experiencing exactly the same!

madebyfabian commented 9 months ago

Just got some help from discord to fix this, it seems that you have to manually remove the quotes around "geography(Point)" in the generated migration sql: https://discord.com/channels/1043890932593987624/1196524721152458862/1196535494675284129

mauriciabad commented 7 months ago

I had the same issue, found a workarround:

  1. Open the migration sql file generated in your editor, and remove the quotes of "geography(Point)".
  2. Add CREATE EXTENSION IF NOT EXISTS postgis; to the top of the file.

This solution is not cool, because we should never touch the generated files... But it is what it is...

Another downside is that adding CREATE EXTENSION IF NOT EXISTS postgis; breaks drizzle-kit push:pg because it adds some new tables that drizzle is not aware of and tries to remove, read more about it here.

mauriciabad commented 3 months ago

Now there's official support for the point type: https://orm.drizzle.team/learn/guides/postgis-geometry-point

robinsimonklein commented 1 month ago

Now there's official support for the point type:

https://orm.drizzle.team/learn/guides/postgis-geometry-point

@mauriciabad For now it looks like this is limited to "geometry" type right ? But "geography" type is not supported, or do I misanderstand something ?

robinsimonklein commented 1 month ago

I started a PR to implement geography point : #3021