Skip to content

PostgreSQL extension management support #12308

Closed

Description

@janpio

Problem

PostgreSQL supports extensions to expand what it supports out of the box.

https://wiki.postgresql.org/wiki/Extensions

Extensions were implemented in PostgreSQL 9.1 to allow for easier packaging of additions to PostgreSQL. Extensions can package user-visible functions or use hooks in the PostgreSQL to modify how the database does certain processes.

You can activate them with this command: https://www.postgresql.org/docs/14/sql-createextension.html
And PostgreSQL can tell you which ones are installed here: https://www.postgresql.org/docs/14/catalog-pg-extension.html
Here is documentation on how to create one yourself: https://www.postgresql.org/docs/14/extend-extensions.html

Popular PostgreSQL extensions are PostGIS, pg_stat_statements, Timescaledb, ltree and many others. PostgreSQL lists some itself at https://www.postgresql.org/download/products/6-postgresql-extensions/, here is a blog post explaining some of these, and there is a full database listing many available extensions.

Hosted PostgreSQL databases often offer some installed PostgreSQL extensions out of the box, or a list of extensions that are explicitly supported and can be enabled. Some examples:

Currently Prisma does not allow you to manage PostgreSQL extensions in a convenient way. This can lead to problems when trying to activate them manually, or use features that require them activated: https://github.com/prisma/prisma/labels/topic%3A%20postgresql-extension There is a manual workaround for Prisma Migrations (see below) but that is hard to discover and does not cover all use and edge cases as it is not deeply integrated into Prisma ORM.

Suggested solution

Somehow reflect the installed or required extensions in Prisma Schema. Optimally this will allow us to both support it in Prisma Introspection, but also Prisma Migrations so they are always installed at the right time and fully support with all our tooling. Features in Prisma schema that require an extension installed, should be able to rely that this is the case.

No suggestion for Prisma schema syntax yet.

Alternatives

Activity

  1. kokokenada commented on Jun 15, 2022

    @kokokenada

    Cross referencing: #6471.
    This problem has been a major complication as I attempt to change from Hasura migrations to prisma migrate. The work around of adding CREATE EXTENSION pgcrypto; as described by https://www.prisma.io/docs/guides/database/developing-with-prisma-migrate/enable-native-database-functions (even as a separate initial migration) simply does not work for me when I run prisma migrate dev. The only workaround I have found so far is to use a shadow database and manually add the extension there.

  2. assigned and unassigned on Sep 30, 2022
  3. added a commit that references this issue on Oct 17, 2022
  4. pimeys commented on Oct 18, 2022

    @pimeys

    Implemented as a preview feature in 4.5.0.

  5. added this to the 4.5.0 milestone on Oct 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions