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

Running db pull after upgrading to 3.x removed name from @@unique #9318

Closed
paustint opened this issue Sep 18, 2021 · 0 comments · Fixed by prisma/prisma-engines#2250
Closed
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: re-introspection
Milestone

Comments

@paustint
Copy link

Bug description

I had an existing unique constraint @@unique([userId, url, uniqueId], name: "uniqueOrg") and I wanted to keep the previously generated db name for this, and following the upgrade guide I ran npx prisma db pull

Expected Result:
@@unique([jetstreamUserId, jetstreamUrl, uniqueId], name: "uniqueOrg", map: "uniqueOrg")

Actual Result:
@@unique([jetstreamUserId, jetstreamUrl, uniqueId], map: "uniqueOrg")

I noticed because after running prisma generate, my code failed to compile because of a mis-named constraint.

How to reproduce

Start with version 2.3
Create a schema and add @@unique with a specific name
push all changes to db
upgrade to v 3.x
run db pull

Expected behavior

The name should be retained
@@unique([jetstreamUserId, jetstreamUrl, uniqueId], name: "uniqueOrg", map: "uniqueOrg")

Prisma information

model SalesforceOrg {
  id                     Int                                       @id @default(autoincrement())
  userId        String                                    @db.VarChar
  uniqueId               String                                    @db.VarChar
  filterText             String                                    @db.VarChar
  accessToken            String                                    @db.VarChar
  instanceUrl            String                                    @db.VarChar
  loginUrl               String                                    @db.VarChar
  userId                 String                                    @db.VarChar(18)
  email                  String                                    @db.VarChar
  organizationId         String                                    @db.VarChar(18)
  username               String                                    @db.VarChar
  displayName            String                                    @db.VarChar
  thumbnail              String?                                   @db.VarChar
  apiVersion             String?                                   @db.VarChar
  orgName                String?                                   @db.VarChar
  orgCountry             String?                                   @db.VarChar
  orgInstanceName        String?                                   @db.VarChar
  orgIsSandbox           Boolean?
  orgLanguageLocaleKey   salesforce_org_orglanguagelocalekey_enum?
  orgNamespacePrefix     String?                                   @db.VarChar
  orgTrialExpirationDate DateTime?                                 @db.Date
  createdAt              DateTime                                  @default(now()) @db.Timestamp(6)
  updatedAt              DateTime                                  @updatedAt
  connectionError        String?                                   @db.VarChar
  url           String?                                   @db.VarChar
  label                  String?                                   @db.VarChar(100)
  orgOrganizationType    String?                                   @db.VarChar

  @@unique([userId, url, uniqueId], name: "uniqueOrg", map: "uniqueOrg")
  @@map("salesforce_org")
}

Environment & setup

  • OS: Mac OS
  • Database: PostgreSQL
  • Node.js version: v15.14.0

Prisma Version

prisma                  : 3.0.2
@prisma/client          : 3.0.2
Current platform        : darwin
Query Engine (Node-API) : libquery-engine 2452cc6313d52b8b9a96999ac0e974d0aedf88db (at node_modules/@prisma/engines/libquery_engine-darwin.dylib.node)
Migration Engine        : migration-engine-cli 2452cc6313d52b8b9a96999ac0e974d0aedf88db (at node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine    : introspection-core 2452cc6313d52b8b9a96999ac0e974d0aedf88db (at node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary           : prisma-fmt 2452cc6313d52b8b9a96999ac0e974d0aedf88db (at node_modules/@prisma/engines/prisma-fmt-darwin)
Default Engines Hash    : 2452cc6313d52b8b9a96999ac0e974d0aedf88db
Studio                  : 0.423.0
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: re-introspection
Projects
None yet
4 participants