Repository navigation
Open
prisma/prisma-engines
#4208Labels
Description
Currently prisma2 does not support spatial types. This is not exactly an edge case since according to google 9% of sql files on github carry out spatial queries.
I was thinking how that feature could work but it’s probably a bit naive given I don’t know the implementation details of prisma2 :
- Have a schema annotation @@spatial so that migrate would create a geometry type in postGIS, a geojson field in mongo etc.
- generate could type this to a geoJSON definition
- client would translate queries to St_FromGeoJSON in postGIS, leave the geoJSON as is in Mongo
The rationale behind this is that you basically want migrate to create the right spatial type in your db, currently schema/code-first does not work and introspect detects spatial as a string. Yuo also want client to perform CRUD on tables containing spatial types, currently CRUD fails if the spatial type is in the select so a .raw request is the only workaround.
Reacted by Matt Zygmunt, Gilles Trenson, Luca Steeb, André L., Samuel Cook, Marek, Antoine, benknab, Rafael Kraut, Juan Manuel Uribe Medina and 374 more
Reacted by LeulAria, Yishay Mendelsohn, ofek berkovich, Omer Hananya, Amin Mohamed Ajani, Jojit Thomas, zeayal, Toktik, felipeskyrocket and ninoish
Reacted by Leonardo E. Dominguez, Daggie Blanqx (Douglas Mwangi), Connor Mahan, Martin, Mohammad Jawad (Kasir) Barati, Mykhailo Marynenko, Ndi-Tah Samweld, hkuper, Daniel Hessel, Oliver Barnwell and 39 more
Reacted by Ray John Alovera, Altay Batuhan, Ghalib Ansari, victor, TJ Klimoski, Christos Tsortanidis, Dion Abrashi, Aubrey Zulu, Amr Aly, Chad Edrupt and 24 more
Reacted by patrick piemonte, გიორგი George Dav, Gustavo Cagnim, reslear, Bertrandmc, Benjamin Tran Dinh, Luis dos Reis, JanChodorowski, Piotr Blachnio, Michal Karták and 64 more
Activity
zifahm commentedon Mar 27, 2020
@teebot is there a workaround for this?
teebot commentedon Mar 27, 2020
Yes!
zifahm commentedon Mar 27, 2020
I would love to see and example @teebot :)
[-]Spatial types support[/-][+]Geolocation/Spatial types support[/+]tctrautman commentedon Jul 25, 2020
Hi all. First time poster here, coming to Prisma from the Redwood community. Thanks for the work you all are doing -- I've really enjoyed working with Prisma 2 and Prisma migrate so far.
Is there a place I can check to see where geo support falls on the Prisma roadmap or, if not, is that something you could speak to here? (Apologies if I missed this in my initial search.)
johanmic commentedon Jul 28, 2020
@tctrautman
cant speak on actual support in the schema annotation but the real issue is the lack of custom types (i.e geography)
hopefully its covered by this #446
which is marked in the next milestone (2.4.0) https://github.com/prisma/prisma/milestone/41
once thats in im hoping that you dont have to fight against migrate that its trying to remove columns thats not in the schema etc. running raw queries is really not an issue for me personally
tctrautman commentedon Aug 3, 2020
Thanks @jaywalklabs -- this is really helpful.
thebiglabasky commentedon Aug 12, 2020
Hi,
Supporting GIS types is not currently planned. We have indeed started picking up native types as mentioned above here #446 but we first focus on the most common types which don't require specific client-side mapping yet.
The roadmap is available at https://pris.ly/roadmap if you want to have an overview of the topics we're tackling and ideas about our timelines
benknab commentedon Aug 12, 2020
@thebiglabasky My only real issue with unsupported GIS types is being unable to use the migration tool. Are you planning to / is it feasible to implement a type or function to flag a field as any type so the migration tool can ignore it?
thebiglabasky commentedon Aug 12, 2020
@bkiac Interesting, that's good context, thanks.
I don't believe we have ironed out the details at this point, but I will surface that idea to the team.
Hebilicious commentedon Aug 22, 2020
I believe supporting GIS types is extremely important, especially given the fact that all the databases that prisma support/plan to support has a way to work with GIS :
@thebiglabasky While I understand that prioritising things can be hard, what I would really like to see in the meantime is improvements when it comes to unhandled cases like this one.
I really like @bkiac idea and it would be nice to take it further by allowing "manual" migrations where custom logic can be written.
Consider a greenfield project that wants to use postgres+postgis with node. In the official example, there's a prisma/posgis/express example repository. In this case, having the ability to use prisma migrate instead of manually running sql scripts +
prisma introspectwould make prisma way more valuable imo.It would be neat if we had the ability to generate custom migrations (with a Laravel-like syntax) :
This would generate a migration folder with a README.md, schema.prisma and steps.json, and would add the migration to the lockfile.
In the data-model the created columns with unsupported types would simply appear with a special annotation/flag.
While this is a little bit rough, at least it would allow the handling of a lot of edge cases and make prisma migrate a much more versatile tool. This would make prisma + prisma migrate a much better standalone tool (no need to manually run sql scripts/introspect anymore).
Having first class geometry/postGIS support would be much better in this example, but implementing something like this in the meantime seems much easier, and would be quite valuable (for example it gives you a way to add postgres functions using a similar manual migration approach).
thebiglabasky commentedon Aug 22, 2020
Thanks for these details!
We are currently rethinking migrate to eventually push it out of the experimental state. At this time, the leading idea is to allow to customize a generated migration. This could serve one aspect of the problem. @albertoperdomo is focusing on migrate with the team and they're looking at how native types will be handled there so there will definitely progress in the right direction in the coming weeks/month.
149 remaining items
marcospgp commentedon Sep 2, 2025
is there an escape hatch for this? as in, can I have columns with geo types in my schema and have the migration tooling not break?
Riki4321 commentedon Sep 3, 2025
+1
goktug7913 commentedon Oct 15, 2025
We're adding telematics stuff, and the lack of geojson support in prisma has become a major issue for us, it's a bit surprising that this isn't given priority. Ingesting coords from 1000+ vehicles and processing data in realtime with a sliding window is kind of painful right now x(
sss-Mihail-sss commentedon Nov 17, 2025
Have the developers given up on this issue?
Toulix commentedon Mar 8, 2026
Any update as of 2026?
nikp29 commentedon Mar 9, 2026
+1
lh0x00 commentedon Mar 21, 2026
I’ve created a PR for this feature. I mentioned it before, but I only just found the time to work on it today. If you’re happy with it, feel free to leave a reaction and follow me—really appreciate it!
PRs: #29365 prisma/prisma-engines#5797 prisma/web#7685
khalidsaidi commentedon Mar 25, 2026
A2ABench has an accepted answer for this imported thread.
ai villagemaroshvarchola commentedon Mar 26, 2026
Wtf is so big problem to implement this? I mean, do we really need to switch from prisma? Like really? Why? Sorry but this is so unprofessional...
lh0x00 commentedon Apr 19, 2026
I created PR this features and using fork version to waiting for merge :)
acidjazz commentedon Apr 22, 2026
drizzle has been great!