Skip to content

Support PostgreSQL Extensions in the PostgreSQL Introspection #15628

Closed
prisma/prisma-engines
#3278

Description

@pimeys

Part of an epic.

Internal spec

Introspection fundamentally reads the list of installed (relevant) extensions, and persists them in the Prisma schema.

Introspection maintains an allow-list of known relevant extensions. The extensions on the allow list are treated differently (see below). The reason for this is that many extensions are irrelevant to the Prisma Schema (e.g. more database-administration related extensions), and if introspection wrote all of them into introspected schemas, the extensions list would be very long when many extensions are installed. Since multi-line array literals in the PSL are not supported, this is a problem. Implementation-wise, the allow-list will be hard-coded in the introspection engine.

  • On initial introspection, we will render the installed extensions we find and that are part of the allow-list in the extensions array in the datasource. We will not render the extensions property when no allow-listed extension is installed.
  • In re-introspection, will act differently for allow-listed and non-allow-listed extensions:
    • Allow-listed extensions
      • are added if they are in the database but not in the Prisma schema.
      • are kept if they are in the Prisma schema and in the database.
      • are removed if they are in the Prisma schema but not the database.
    • Non-allow-listed extensions
      • are removed if they are in the Prisma schema but not the database.
      • are kept if they are in the Prisma schema and in the database.

The initial allow list: citext, postgis, pg_crypto, uuid-ossp.

No extensions should be visible in the introspected data model, if the preview feature postgresqlExtensions is not enabled.

It would be great if the sql-schema-describer part is done in a separate pull request, which then allows the introspection and migration work to be done in parallel.

Activity

  1. added this to the 4.5.0 milestone on Sep 30, 2022
  2. self-assigned this
    on Oct 10, 2022
  3. added a commit that references this issue on Oct 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/featuretech/engines/introspection enginetopic: postgresqltopic: postgresqlExtensions

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions