Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

db pull with multiSchema error on schema with 2 models with the same table name but in a different schema #15800

Closed
Jolg42 opened this issue Oct 14, 2022 · 1 comment · Fixed by prisma/prisma-engines#3297
Assignees
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/schema Issue for team Schema. topic: introspection topic: multiSchema multiple schemas topic: prisma db pull CLI: prisma db pull
Milestone

Comments

@Jolg42
Copy link
Member

Jolg42 commented Oct 14, 2022

Bug description

I get the following error when introspecting my PostgreSQL database

Error: [libs/dml/src/datamodel.rs:178:14] Every RelationInfo should have a complementary RelationInfo on the opposite relation field.

How to reproduce

  • create schema.prisma file
  • create PostgreSQL database from provided SQL
  • npx prisma db pull
  • Get error

Expected behavior

It should work?

Prisma information

datasource db {
  provider = "postgres"
  url      = env("TEST_POSTGRES_URI")
  schemas  = ["base", "transactional"]
}

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["multiSchema"]
}
-- CreateSchema
CREATE SCHEMA IF NOT EXISTS "base";

-- CreateSchema
CREATE SCHEMA IF NOT EXISTS "transactional";

--
-- tables names are renamed so they are identical
-- Original names are User and Post
--  

-- CreateTable
CREATE TABLE "base"."some_table" (
    "id" TEXT NOT NULL,
    "email" TEXT NOT NULL,

    CONSTRAINT "User_pkey2" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "transactional"."some_table" (
    "id" TEXT NOT NULL,
    "title" TEXT NOT NULL,
    "authorId" TEXT NOT NULL,

    CONSTRAINT "Post_pkey2" PRIMARY KEY ("id")
);

-- AddForeignKey
ALTER TABLE "transactional"."some_table" ADD CONSTRAINT "Post_authorId_fkey2" FOREIGN KEY ("authorId") REFERENCES "base"."some_table"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

Environment & setup

  • OS: macOS
  • Database: PostgreSQL
  • Node.js version: v16

Prisma Version

Dev setup with engines 4.5.0-35.7ed9e65490b6d360d03e2b531da2db29b6c7b919

@Jolg42 Jolg42 added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. topic: introspection team/schema Issue for team Schema. topic: prisma db pull CLI: prisma db pull topic: multiSchema multiple schemas labels Oct 14, 2022
@Jolg42 Jolg42 added this to the 4.5.0 milestone Oct 14, 2022
@tomhoule
Copy link
Contributor

The crash is reproduced in a test in prisma/prisma-engines#3297

@janpio janpio modified the milestones: 4.5.0, 4.6.0 Oct 18, 2022
@janpio janpio modified the milestones: 4.6.0, 4.7.0 Nov 8, 2022
tomhoule added a commit to prisma/prisma-engines that referenced this issue Nov 25, 2022
The test expectations show that there are cases where our choice _not_
to rename models and enums in case of conflict leads to ambiguous
situations that may be difficult for users to resolve. The test case
where this is the most apparent is
`multiple_schemas_w_duplicate_enums_are_introspected`.

closes prisma/prisma#15800
tomhoule added a commit to prisma/prisma-engines that referenced this issue Nov 25, 2022
The test expectations show that there are cases where our choice _not_
to rename models and enums in case of conflict leads to ambiguous
situations that may be difficult for users to resolve. The test case
where this is the most apparent is
`multiple_schemas_w_duplicate_enums_are_introspected`.

closes prisma/prisma#15800
tomhoule added a commit to prisma/prisma-engines that referenced this issue Nov 25, 2022
Test postgres multi-schema introspection

The test expectations show that there are cases where our choice _not_
to rename models and enums in case of conflict leads to ambiguous
situations that may be difficult for users to resolve. The test case
where this is the most apparent is
`multiple_schemas_w_duplicate_enums_are_introspected`.

closes prisma/prisma#15800
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/schema Issue for team Schema. topic: introspection topic: multiSchema multiple schemas topic: prisma db pull CLI: prisma db pull
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants