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

Unreachable shadowDatabaseUrl leads to confusing output #7341

Open
janpio opened this issue May 29, 2021 · 2 comments
Open

Unreachable shadowDatabaseUrl leads to confusing output #7341

janpio opened this issue May 29, 2021 · 2 comments
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/schema Issue for team Schema. tech/engines Issue for tech Engines. topic: error topic: prisma migrate dev CLI: prisma migrate dev topic: shadow database

Comments

@janpio
Copy link
Member

janpio commented May 29, 2021

Bug description

C:\Users\Jan\Documents\throwaway\planetscale>npx prisma migrate dev --create-only
Environment variables loaded from .env
Prisma schema loaded from prisma\schema.prisma
Datasource "db": MySQL database "fk-test2" at "127.0.0.1:3306"

Error: P1001

Can't reach database server at `localhost`:`3333`

Please make sure your database server is running at `localhost`:`3333` which can lead to very confusing debugging sessions.

Note the different ports

How to reproduce

Define schema and env as below, only run the main database but not the shadow database.

Expected behavior

Optimal: Better error message that mentions shadow database.
Pragmatic: Shadow database could also get output line a la Datasource "db": MySQL database "fk-test2" at "127.0.0.1:3306", so error message would just not be a full surprise.

Prisma information

.env

DATABASE_URL="mysql://root:@127.0.0.1:3306/fk-test2"
SHADOW_DATABASE_URL="mysql://root:@localhost:3333/fk-test2"

schema:

datasource db {
  provider          = "mysql"
  url               = env("DATABASE_URL")
  shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
}

Environment & setup

  • OS: WIndows
  • Database:

Prisma Version

2.23.0

@janpio janpio added 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: prisma migrate dev CLI: prisma migrate dev labels May 29, 2021
@pantharshit00 pantharshit00 added bug/2-confirmed Bug has been reproduced and confirmed. and removed bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. labels May 31, 2021
@tomhoule tomhoule added this to the 2.25.0 milestone Jun 2, 2021
@tomhoule tomhoule self-assigned this Jun 11, 2021
@tomhoule
Copy link
Contributor

I dived into the CLI code to see if we could make it happen easily, and it turns out that the "print database info" functionality in the CLI depends on the DMMF, which is going to be brittle and more involved than it needs to be. This is one more argument for moving this logic into engines (mentioned frequently in the past). I opened and candidated an issue: https://github.com/prisma/migrations-team/issues/246

@tomhoule tomhoule removed their assignment Jun 14, 2021
@tomhoule tomhoule removed this from the 2.25.0 milestone Jun 17, 2021
@janpio janpio added kind/improvement An improvement to existing feature and code. and removed bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. labels Sep 9, 2021
@janpio janpio added bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. and removed kind/improvement An improvement to existing feature and code. labels Sep 23, 2021
@do4gr
Copy link
Member

do4gr commented Jan 12, 2022

Here wrapping the error from the shadowdb to tell the user that that's where it came from this would be much clearer.

@janpio janpio added tech/engines Issue for tech Engines. tech/typescript Issue for tech TypeScript. labels Mar 24, 2022
@janpio janpio removed the tech/typescript Issue for tech TypeScript. label Apr 4, 2022
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. tech/engines Issue for tech Engines. topic: error topic: prisma migrate dev CLI: prisma migrate dev topic: shadow database
Projects
None yet
Development

No branches or pull requests

6 participants