Skip to content

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

Closed as not planned

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

Activity

  1. added
    kind/bug
    on Sep 1, 2024
  2. added
    bug/1-unconfirmed
    tech/engines/introspection engine
    on Sep 2, 2024
  3. FGoessler commented on Jan 23, 2025

    @FGoessler
    Contributor

    Hi,

    We’ve noticed there hasn’t been activity on this issue for quite some time, and we suspect it might no longer be relevant. As part of our ongoing effort to streamline open issues in this repository, we’re closing this one to focus on what’s most important to our community.

    If you believe this issue is still relevant and requires attention, feel free to reopen it. Reopening the issue is a valuable signal to us about what matters most to you.

    You can learn more about our approach and motivations in the Prisma ORM Manifesto.

    With love,
    Your Prisma ORM Team ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug/1-unconfirmedkind/bugtech/engines/introspection enginetopic: postgresqltopic: timescaledb

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions