prisma: Support Amazon RedShift (Currently `No such table: information_schema.sequence` error on `npx prisma db pull`)

Bug description

I am attempting to connect a Redshift database to Prisma using the postgresql drivers. I did the setup as outlined here successfully. i followed the database url instructions found here with my credentials matching the following pattern:

postgresql://username:password@abc-12-345-67-890.eu-west-1.redshift.amazonaws.com:1234/databaseName?schema=foo&readOnlyMode=always

i run DEBUG="*" npx prisma db pull and i get the following error:

 prisma:engines binaries to download libquery-engine, migration-engine, introspection-engine, prisma-fmt +0ms
Prisma schema loaded from prisma/schema.prisma
  prisma:loadEnv project root found at ./package.json +0ms       
  prisma:tryLoadEnv Environment variables loaded from ./.env +0ms
Environment variables loaded from .env
  prisma:getConfig Using CLI Query Engine (Node-API Library) at: ./node_modules/@prisma/engines/libquery_engine-debian-openssl-1.1.x.so.node +0ms
Datasource "db": PostgreSQL database "databaseName", schema "foo" at "abc-12-345-67-890.eu-west-1.redshift.amazonaws.com:1234"

Introspecting based on datasource defined in prisma/schema.prisma …
  prisma:introspectionEngine:rpc starting introspection engine with binary: ./node_modules/@prisma/engines/introspection-engine-debian-openssl-1.1.x +0ms
  prisma:introspectionEngine:rpc SENDING RPC CALL {"id":1,"jsonrpc":"2.0","method":"introspect","params":[{"schema":"// This is your Prisma schema file,\n// learn more about it in the docs: https://pris.ly/d/prisma-schema\n\ngenerator client {\n  provider = \"prisma-client-js\"\n}\n\ndatasource db {\n  provider = \"postgresql\"\n  url      = env(\"DATABASE_URL\")\n}\n"}]} +21ms
  prisma:introspectionEngine:rpc {
  prisma:introspectionEngine:rpc   jsonrpc: '2.0',
  prisma:introspectionEngine:rpc   error: {
  prisma:introspectionEngine:rpc     code: 4466,
  prisma:introspectionEngine:rpc     message: 'An error happened. Check the data field for details.',
  prisma:introspectionEngine:rpc     data: {
  prisma:introspectionEngine:rpc       is_panic: false,
  prisma:introspectionEngine:rpc       message: 'Error in connector: Error querying the database: Error querying the database: No such table: information_schema.sequences',
  prisma:introspectionEngine:rpc       backtrace: null
  prisma:introspectionEngine:rpc     }
  prisma:introspectionEngine:rpc   },
  prisma:introspectionEngine:rpc   id: 1
  prisma:introspectionEngine:rpc } +868ms

Error: Error: Error in connector: Error querying the database: Error querying the database: No such table: information_schema.sequences

    at Object.<anonymous> (./node_modules/prisma/build/index.js:46523:29)
    at Object.handleResponse ./node_modules/prisma/build/index.js:46401:38)
    at LineStream4.<anonymous> (./node_modules/prisma/build/index.js:46479:20)
    at LineStream4.emit (node:events:390:28)
    at addChunk (node:internal/streams/readable:315:12)
    at readableAddChunk (node:internal/streams/readable:289:9)
    at LineStream4.Readable.push (node:internal/streams/readable:228:10)
    at LineStream4._pushBuffer (./node_modules/prisma/build/index.js:46244:21)
    at LineStream4._transform (./node_modules/prisma/build/index.js:46238:12)
    at LineStream4.Transform._write (node:internal/streams/transform:184:23)

i use the same database url for my current postgres drivers with KnexJS, and would like to migrate to Prisma for it’s ability to sync data models with my database.

How to reproduce

  1. have a Redshift database that you can connect to with postgres drivers
  2. initialize Prisma for an existing project
  3. run DEBUG="*" npx prisma db pull
  4. see error

Expected behavior

I expect the initialization to happen without an error.

Prisma information

from .env:

# Environment variables declared in this file are automatically made available to Prisma.

# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema

# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB (Preview) and CockroachDB (Preview).

# See the documentation for all the connection string options: https://pris.ly/d/connection-strings

DATABASE_URL="postgresql://username:password@abc-12-345-67-890.eu-west-1.redshift.amazonaws.com:1234/databaseName?schema=foo&readOnlyMode=always"

from schema.prisma:


// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

Environment & setup

  • OS: Windows 10, 64-bit, WSL1 using Ubuntu 18.04
  • Database: Redshift with Postgresql drivers
  • Node version: v16.13.2

Prisma Version

Environment variables loaded from .env
prisma                  : 3.9.2
@prisma/client          : Not found
Current platform        : debian-openssl-1.1.x
Query Engine (Node-API) : libquery-engine bcc2ff906db47790ee902e7bbc76d7ffb1893009 (at node_modules/@prisma/engines/libquery_engine-debian-openssl-1.1.x.so.node)
Migration Engine        : migration-engine-cli bcc2ff906db47790ee902e7bbc76d7ffb1893009 (at node_modules/@prisma/engines/migration-engine-debian-openssl-1.1.x)
Introspection Engine    : introspection-core bcc2ff906db47790ee902e7bbc76d7ffb1893009 (at node_modules/@prisma/engines/introspection-engine-debian-openssl-1.1.x)
Format Binary           : prisma-fmt bcc2ff906db47790ee902e7bbc76d7ffb1893009 (at node_modules/@prisma/engines/prisma-fmt-debian-openssl-1.1.x)
Default Engines Hash    : bcc2ff906db47790ee902e7bbc76d7ffb1893009
Studio                  : 0.457.0

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 5
  • Comments: 22 (9 by maintainers)

Most upvoted comments

FYI Also trying to use Prisma with Redshift and ran into this bug.

@MJGTwo I’m wondering if you have a work around or are you just not using Prisma for this use case?

None we are aware of. Last time we checked, RedShift was not emulating this standard PostgreSQL database table that we require on db pull.

Ok, had another look. The error message explicitly mentions information_schema.sequence. Via this SO answer we know that this does not exist for Redshift https://stackoverflow.com/a/68232305 and can confirm as https://docs.aws.amazon.com/redshift/latest/dg/c_unsupported-postgresql-features.html is listed there. Seems Prisma by default tries to read that table (to get the full information about tables and their structure), while the GUIs mentioned do not.

We can probably just not crash and assume no results if that query does not work and potentially unblock Redshift with that.

You can try migrating the same schema on a PostgreSQL, then db pull on that and then use the resulting Prisma Schema with your Redshift instance. That would let you skip the problem above (the missing table is not used when just using Prisma Client) - but of course there might be other, unknown problems waiting for you there.

Yes, but it might be as simple as skipping the sequences query or not crashing when the query does not work:

Relevant code on our side:

Obviously this might just uncover further, until now hidden problematic queries. Only one way to find out 😆

  • does the ?schema=public always have to be equal to public? for my usage, i have the value analytics to make DBeaver work because that schema contains the tables I an querying against

No, that is indeed a supported feature of Prisma that you can set whatever schema name you want there.

  • do I need to have readOnly=true or readOnlyMode=always to make Prisma read only for Redshift?

Most probably not.

Introspection depends on some system databases and tables being present, and one of those seems to be missing for Redshift with PostgreSQL. https://docs.aws.amazon.com/redshift/latest/dg/c_redshift-and-postgres-sql.html mentions something in that direction:

Because it addresses very different requirements, the specialized data storage schema and query execution engine that Amazon Redshift uses are completely different from the PostgreSQL implementation.

Can you generally use this PostgreSQL connection string in database UIs like DBeaver or similar?