Skip to content

[PostGIS] Using geometry type for column causes schema validation error #29566

Open

Description

@TanguyP

Bug description

Can't create a migration to add a (table containing a) PostGIS column like geometry - even the example from the doc is not working. Maybe I've missed something?

Severity

⚠️ Major: Breaks core functionality (e.g., migrations fail)

Reproduction

  1. Set up a PostgreSQL (18.) / PostGIS (3.6.) DB
  2. Create a few tables in it (manually)
  3. Set up a Prisma project to manage migrations for your DB (following the Prisma documentation for existing DBs), and be sure to add CREATE EXTENSION IF NOT EXISTS postgis; in your initial migration file
  4. Try adding some columns/tables (using standard Postgres types) to the schema file, and generating/applying Prisma migrations, to verify that non-PostGIS migrations are working fine
  5. In your schema.prisma file, add a table with a geometry, as explained in the docs:
model Location {
  id       Int      @id @default(autoincrement())
  name     String
  position Geometry(Point, 4326)? // [!code highlight]
}
  1. Try to create the migration file: bunx --bun prisma migrate dev --create-only --name create-location

Expected vs. Actual Behavior

Expected result

The migration file should be created (and the table should be created in your DB if you omit the --create-only flag).

Actual result

The command fails with the following output:

Loaded Prisma config from prisma.config.ts.
Prisma schema loaded from prisma\schema.prisma.
Error: Prisma schema validation - (get-config wasm)
Error code: P1012
error: Error validating: This line is not a valid field or attribute definition.
  -->  prisma\schema.prisma:245
   |
244 |   name     String
245 |   position Geometry(Point, 4326)? // [!code highlight]
246 | }
   |

Validation Error Count: 1
[Context: getConfig]
Prisma CLI Version : 7.8.0

Frequency

Consistently reproducible

Does this occur in development or production?

Both development and production

Is this a regression?

No idea

Workaround

Using Unsupported("geometry") instead of Geometry* works. But that's only a workaround, because I want to benefit from Prisma's PostGIS integration, not just create a column which is meaningless to Prisma.

Prisma Schema & Queries

model Location {
  id       Int      @id @default(autoincrement())
  name     String
  position Geometry(Point, 4326)? // [!code highlight]
}
// N/A

Prisma Config

// Standard file, didn't change anything

Logs & Debug Info

// Debug logs here

Environment & Setup

  • OS: Windows 11
  • Database: PostgreSQL 18, PostGIS 3.6
  • Node.js version: Bun 1.3.13

Prisma Version

7.8.0

Activity

  1. vitzalt commented on May 18, 2026

    @vitzalt

    Prisma doesn't actually have PostGIS integration, the feature is not merged or reviewed yet. The docs are incorrect. The Prisma team have not acknowledged this even though it has been raised with them multiple times.

    #29365
    prisma/prisma-engines#5797
    #2789

  2. TanguyP commented on May 18, 2026

    @TanguyP
    Author

    Ok, thanks a lot for clarifying! If the PR is still delayed, it may make more sense to open a PR to add an explanation banner on top of the Prisma+PostGIS doc page which got merged too early - hopefully this new PR would get merged faster. I'll check if I can find some time for this.

  3. lh0x00 commented on Aug 7, 2026

    @lh0x00

    Since this PR hasn't merged, I've published the same PostGIS fork to npm as @vertexa/prisma, @vertexa/prisma-client, and @vertexa/prisma-adapter-pg (v7.8.6) — drop-in
    replacements that add Geometry/Geography scalar types, near/within/intersects spatial
    filters, distanceFrom ordering, and automatic GeoJSON ↔ EWKB serialization.

    npm install @vertexa/prisma @vertexa/prisma-client @vertexa/prisma-adapter-pg

    {
      "pnpm": {
        "overrides": {
          "@prisma/client": "npm:@vertexa/prisma-client@7.8.6",
          "@prisma/adapter-pg": "npm:@vertexa/prisma-adapter-pg@7.8.6"
        }
      }
    }
    model Location {
      id       Int      @id @default(autoincrement())
      name     String
      position Geometry(Point, 4326)?
    }
    const nearby = await prisma.location.findMany({
      where: { position: { near: { point: [13.4, 52.5], maxDistance: 1000 } } },
      orderBy: { position: { distanceFrom: { point: [13.4, 52.5], direction: 'asc' } } },
      take: 10,
    })
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