Skip to content

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

@TanguyP

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions