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

Using --url for db pull ignored/overwrites provider=cockroachdb #11527

Closed
Tracked by #12385
janpio opened this issue Jan 31, 2022 · 3 comments · Fixed by #12910
Closed
Tracked by #12385

Using --url for db pull ignored/overwrites provider=cockroachdb #11527

janpio opened this issue Jan 31, 2022 · 3 comments · Fixed by #12910
Assignees
Labels
kind/improvement An improvement to existing feature and code. team/schema Issue for team Schema. tech/engines Issue for tech Engines. tech/typescript Issue for tech TypeScript. topic: cockroachdb topic: internal topic: prisma db pull CLI: prisma db pull topic: re-introspection
Milestone

Comments

@janpio
Copy link
Member

janpio commented Jan 31, 2022

With this schema:

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

datasource db {
  provider = "cockroachdb"
  url      = "postgresql://jo_l:11...oud:26257/introspection-ci-5134.aragon-notification-service?sslmode=verify-full"
}

this is the output of prisma db pull --url=postgresql://jo....cloud:26257/introspection-ci-5134.aragon-notification-service?sslmode=verify-full:

λ npx prisma db pull --url=postgresql://jo_l:1...oud:26257/introspection-ci-5134.aragon-notification-service?sslmode=verify-full
Environment variables loaded from .env
Prisma schema loaded from prisma\schema.prisma
Datasource "db": CockroachDB database "introspection-ci-5134.aragon-notification-service", schema "public" at "free-tier...ud:26257"

Introspecting …

✔ Introspected 6 models and wrote them into prisma\schema.prisma in 6.80s

Run prisma generate to generate Prisma Client.

(which is great!)

but this the resulting schema:

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

datasource db {
  provider = "postgresql"
  url      = "postgresql://jo_l:11ekBxMQuUr07kHv@free-tier.gcp-us-central1.cockroachlabs.cloud:26257/introspection-ci-5134.aragon-notification-service?sslmode=verify-full"
}

model eventsources {
  eventsource_id   BigInt          @id
  created_at       DateTime?       @default(now()) @db.Timestamptz(6)
  enabled          Boolean         @default(true)
  contract_address String          @db.VarChar(255)

Note how it says provider = "postgresql" there.

I think it would be ok to keep ´provider=cockroachdb` around when already set in the original schema.

(Everything works fine when you just run db pull without --url)

Related: #11347

@janpio janpio added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. topic: prisma db pull CLI: prisma db pull topic: cockroachdb labels Jan 31, 2022
@janpio janpio added topic: internal team/schema Issue for team Schema. kind/improvement An improvement to existing feature and code. and removed bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. labels Jan 31, 2022
@janpio janpio added topic: re-introspection tech/engines Issue for tech Engines. tech/typescript Issue for tech TypeScript. labels Apr 5, 2022
@janpio
Copy link
Member Author

janpio commented Apr 7, 2022

Related: #11347 (comment)

@janpio janpio added this to the 3.13.0 milestone Apr 11, 2022
@jkomyno jkomyno self-assigned this Apr 21, 2022
@tomhoule
Copy link
Contributor

In the current implementation, it seems like we are converting the url passed to --url into a datasource, without taking into account the prisma schema (

schema = this.urlToDatasource(url)
) — alternatively, the CLI could send both to the introspection engine, which would figure out the right provider naturally from parsing the prisma schema. If we do that in the typescript code, we will have to introduce more logic and more special cases, so I think ideally, we should handle this in the introspection engine.

@jkomyno
Copy link
Contributor

jkomyno commented Apr 21, 2022

In the current implementation, it seems like we are converting the url passed to --url into a datasource, without taking into account the prisma schema (

schema = this.urlToDatasource(url)

) — alternatively, the CLI could send both to the introspection engine, which would figure out the right provider naturally from parsing the prisma schema. If we do that in the typescript code, we will have to introduce more logic and more special cases, so I think ideally, we should handle this in the introspection engine.

Exactly, I have realized the root cause yesterday afternoon, I will publish my local changes (which solve this issue) soon this morning :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/improvement An improvement to existing feature and code. team/schema Issue for team Schema. tech/engines Issue for tech Engines. tech/typescript Issue for tech TypeScript. topic: cockroachdb topic: internal topic: prisma db pull CLI: prisma db pull topic: re-introspection
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants