Skip to content

Geolocation/Spatial types support #1798

Open
prisma/prisma-engines
#4208

Description

@teebot

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.

Activity

  1. zifahm commented on Mar 27, 2020

    @zifahm

    @teebot is there a workaround for this?

  2. teebot commented on Mar 27, 2020

    @teebot
    Author

    Yes!

    • When you introspect geometry types will be marked as strings in your schema
    • Exclude these types from your crud queries
    • when you need them make a raw query and expose as geojson then json parse the string
  3. zifahm commented on Mar 27, 2020

    @zifahm

    I would love to see and example @teebot :)

  4. changed the title [-]Spatial types support[/-] [+]Geolocation/Spatial types support[/+] on Jun 25, 2020
  5. tctrautman commented on Jul 25, 2020

    @tctrautman

    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.)

  6. johanmic commented on Jul 28, 2020

    @johanmic

    @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

  7. tctrautman commented on Aug 3, 2020

    @tctrautman

    Thanks @jaywalklabs -- this is really helpful.

  8. thebiglabasky commented on Aug 12, 2020

    @thebiglabasky

    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

  9. benknab commented on Aug 12, 2020

    @benknab

    @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?

  10. thebiglabasky commented on Aug 12, 2020

    @thebiglabasky

    @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.

  11. Hebilicious commented on Aug 22, 2020

    @Hebilicious

    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 introspect would make prisma way more valuable imo.
    It would be neat if we had the ability to generate custom migrations (with a Laravel-like syntax) :

    //CustomMigration.ts
    export const up = async () => {
    //Raw SQL logic that creates tables/columns/install extensions etc
    }
    export const down = async () => {
    //Raw SQL logic that tear down things created by "up"
    }

    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).

  12. thebiglabasky commented on Aug 22, 2020

    @thebiglabasky

    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.

  13. 149 remaining items

  14. marcospgp commented on Sep 2, 2025

    @marcospgp

    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?

  15. Riki4321 commented on Sep 3, 2025

    @Riki4321

    +1

  16. goktug7913 commented on Oct 15, 2025

    @goktug7913

    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(

  17. sss-Mihail-sss commented on Nov 17, 2025

    @sss-Mihail-sss

    Have the developers given up on this issue?

  18. Toulix commented on Mar 8, 2026

    @Toulix

    Any update as of 2026?

  19. nikp29 commented on Mar 9, 2026

    @nikp29

    +1

  20. lh0x00 commented on Mar 21, 2026

    @lh0x00

    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

  21. khalidsaidi commented on Mar 25, 2026

    @khalidsaidi

    A2ABench has an accepted answer for this imported thread.

  22. maroshvarchola commented on Mar 26, 2026

    @maroshvarchola

    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...

  23. lh0x00 commented on Apr 19, 2026

    @lh0x00

    I created PR this features and using fork version to waiting for merge :)

  24. acidjazz commented on Apr 22, 2026

    @acidjazz

    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...

    drizzle has been great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions