Skip to content

Timescaledb foreign key reference does not play nicely with introspection  #25135

@KilianB

Description

@KilianB

Bug description

With the new 2.16 release of timescaledb hypertables now support foreign key references to and from the hypertables.

Pullrequest: timescale/timescaledb#6989
Release version: https://github.com/timescale/timescaledb/releases/tag/2.16.0

Error: P4002

The schema of the introspected database was inconsistent: The schema of the introspected database was inconsistent: Cross schema references are only allowed when the target schema is listed in the schemas property of your datasource. 
`public......` points to `_timescaledb_internal._hyper_3_9_chunk` in constraint `......`. Please add `_timescaledb_internal` to your `schemas` property and run this command again.

Ref: #3228

When adding _timescaledb_internal to the schemas it will complain about all the reference schemas to be included as well like _timescaledb_config and _timescaledb_catalog. Migration will randomly fail as Timescale dbs internal will add more tables on an as need basis to partition chunks so the prisma schema will always be outdated.

Prisma has no business in controlling those tables and schemas.

How to reproduce

Install the timescaledb extension
Add a hypertable and add a relation to and from it

Expected behavior

Timescale dbs foreign key references should be usable with prisma

Prisma information

No shareable schema exists right now

Environment & setup

  • Database: PostgreSQL 16.4 (Ubuntu 16.4-1.pgdg24.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 13.2.0-23ubuntu4) 13.2.0, 64-bit
  • Timescaledb 16.2

Prisma Version

prisma                  : 5.19.0
@prisma/client          : 5.19.0
Computed binaryTarget   : windows
Operating System        : win32
Architecture            : x64
Node.js                 : v21.4.0
Query Engine (Node-API) : libquery-engine 5fe21811a6ba0b952a3bc71400666511fe3b902f (at ..\..\node_modules\@prisma\engines\query_engine-windows.dll.node)
Schema Engine           : schema-engine-cli 5fe21811a6ba0b952a3bc71400666511fe3b902f (at ..\..\node_modules\@prisma\engines\schema-engine-windows.exe)
Schema Wasm             : @prisma/prisma-schema-wasm 5.19.0-31.5fe21811a6ba0b952a3bc71400666511fe3b902f
Default Engines Hash    : 5fe21811a6ba0b952a3bc71400666511fe3b902f
Studio                  : 0.502.0
Preview Features        : multiSchema, nativeDistinct, postgresqlExtensions, views, relationJoins

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions