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

referentialIntegrity policy is lost during re-introspection #16007

Closed
jkomyno opened this issue Oct 26, 2022 · 1 comment · Fixed by prisma/prisma-engines#3337
Closed

referentialIntegrity policy is lost during re-introspection #16007

jkomyno opened this issue Oct 26, 2022 · 1 comment · Fixed by prisma/prisma-engines#3337
Assignees
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/schema Issue for team Schema. topic: re-introspection topic: referentialIntegrity/relationMode
Milestone

Comments

@jkomyno
Copy link
Contributor

jkomyno commented Oct 26, 2022

Bug description

Given the following example schema:

generator client {
    provider        = "prisma-client-js"
    previewFeatures = ["referentialIntegrity"]
}

datasource db {
    provider             = "sqlite"
    url                  = env("TEST_DATABASE_URL")
    referentialIntegrity = "prisma"
}

model Foo {
    id     Int @id
    bar    Bar @relation(fields: [bar_id], references: [id])
    bar_id Int @unique
}

model Bar {
    id  Int  @id
    foo Foo?
}

reintrospection results in the following:

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["referentialIntegrity"]
}

// notice that `referentialIntegrity = "prisma" is gone.
datasource db {
  provider = "sqlite"
  url      = env("TEST_DATABASE_URL")
}

model Foo {
  id     Int @id @default(autoincrement())
  bar_id Int @unique
  bar    Bar @relation(fields: [bar_id], references: [id])
}

model Bar {
  id  Int  @id @default(autoincrement())
  foo Foo?
}

How to reproduce

  • prisma db push
  • prisma db pull

Expected behavior

The referentialIntegrity policy, i.e. referentialIntegrity = "prisma", should be preserved during re-introspection.

Prisma information

Environment & setup

  • OS: MacOS M1
  • Node.js version: 18.11.0

Prisma Version

prisma                  : 4.5.0
@prisma/client          : Not found
Current platform        : darwin-arm64
Query Engine (Node-API) : libquery-engine 0362da9eebca54d94c8ef5edd3b2e90af99ba452 (at ../../../Library/pnpm/store/v3/tmp/dlx-41902/node_modules/.pnpm/@prisma+engines@4.5.0/node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node)
Migration Engine        : migration-engine-cli 0362da9eebca54d94c8ef5edd3b2e90af99ba452 (at ../../../Library/pnpm/store/v3/tmp/dlx-41902/node_modules/.pnpm/@prisma+engines@4.5.0/node_modules/@prisma/engines/migration-engine-darwin-arm64)
Introspection Engine    : introspection-core 0362da9eebca54d94c8ef5edd3b2e90af99ba452 (at ../../../Library/pnpm/store/v3/tmp/dlx-41902/node_modules/.pnpm/@prisma+engines@4.5.0/node_modules/@prisma/engines/introspection-engine-darwin-arm64)
Format Binary           : prisma-fmt 0362da9eebca54d94c8ef5edd3b2e90af99ba452 (at ../../../Library/pnpm/store/v3/tmp/dlx-41902/node_modules/.pnpm/@prisma+engines@4.5.0/node_modules/@prisma/engines/prisma-fmt-darwin-arm64)
Format Wasm             : @prisma/prisma-fmt-wasm 4.5.0-43.0362da9eebca54d94c8ef5edd3b2e90af99ba452
Default Engines Hash    : 0362da9eebca54d94c8ef5edd3b2e90af99ba452
Studio                  : 0.476.0
@jkomyno jkomyno added kind/bug A reported bug. team/schema Issue for team Schema. labels Oct 26, 2022
@jkomyno jkomyno self-assigned this Oct 26, 2022
@jkomyno jkomyno added this to the 4.6.0 milestone Oct 26, 2022
@jkomyno jkomyno added the bug/2-confirmed Bug has been reproduced and confirmed. label Oct 26, 2022
@Jolg42 Jolg42 changed the title referentialIntegrity policy is lost during introspection referentialIntegrity policy is lost during re-introspection Oct 26, 2022
@Jolg42
Copy link
Member

Jolg42 commented Oct 26, 2022

Note from Alberto, this applies to referentialIntegrity = "foreignKeys" and referentialIntegrity = "prisma"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/schema Issue for team Schema. topic: re-introspection topic: referentialIntegrity/relationMode
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants