P4001 The introspected database was empty

See original GitHub issue

Bug description

When I initiate the introspect process I receive the above mentioned error waring

How to reproduce

  1. npm install @prisma/cli
  2. Enter my heroku postgresql url into the DATABASE_URL variable in prisma/.env
  3. npx run intropect

Expected behavior

I expected my database to be interrogated and the appropriate models to be created in the schema.

Prisma information

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

generator client {
  provider = "prisma-client-js"
}

Environment & setup

  • OS: Windows
  • Database: PostgreSQL
  • Prisma version: 2.2.0
  • Node.js version: 10.16.0

Additional information

heroku-postgresql

Logs

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Users\\d0475\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'introspect' ]
2 info using npm@6.5.0
3 info using node@v10.16.0
4 verbose run-script [ 'preintrospect', 'introspect', 'postintrospect' ]
5 info lifecycle flamingo-backend@1.0.0~preintrospect: flamingo-backend@1.0.0
6 info lifecycle flamingo-backend@1.0.0~introspect: flamingo-backend@1.0.0
7 verbose lifecycle flamingo-backend@1.0.0~introspect: unsafe-perm in lifecycle true
8 verbose lifecycle flamingo-backend@1.0.0~introspect: PATH: C:\Users\d0475\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\d0475\Documents\Projects\flamingo-ecom2\sick-fits\backend\node_modules\.bin;C:\Users\d0475\Documents\Cmder\bin;C:\Program Files\Git\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\share\vim\vim74;C:\Users\d0475\Documents\Cmder\vendor\conemu-maximus5\ConEmu\Scripts;C:\Users\d0475\Documents\Cmder\vendor\conemu-maximus5;C:\Users\d0475\Documents\Cmder\vendor\conemu-maximus5\ConEmu;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Calibre2\;C:\WINDOWS\System32\LibreSSL\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\nodejs\;C:\Program Files (x86)\Yarn\bin\;C:\Program Files (x86)\Gpg4win\..\GnuPG\bin;C:\Program Files\Git\cmd;C:\Users\d0475\AppData\Local\Microsoft\WindowsApps;C:\Users\d0475\AppData\Local\Microsoft\WindowsApps;;C:\Users\d0475\AppData\Local\now-cli;C:\Program Files\Heroku\bin;C:\Program Files\Microsoft VS Code\bin;C:\Users\d0475\AppData\Local\hyper\app-2.0.0\resources\bin;C:\Users\d0475\AppData\Roaming\npm;C:\Users\d0475\AppData\Local\Yarn\bin;C:\Users\d0475\Documents\Cmder
9 verbose lifecycle flamingo-backend@1.0.0~introspect: CWD: C:\Users\d0475\Documents\Projects\flamingo-ecom2\sick-fits\backend
10 silly lifecycle flamingo-backend@1.0.0~introspect: Args: [ '/d /s /c', 'npx prisma introspect' ]
11 silly lifecycle flamingo-backend@1.0.0~introspect: Returned: code: 1  signal: null
12 info lifecycle flamingo-backend@1.0.0~introspect: Failed to exec introspect script
13 verbose stack Error: flamingo-backend@1.0.0 introspect: `npx prisma introspect`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Users\d0475\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
13 verbose stack     at EventEmitter.emit (events.js:198:13)
13 verbose stack     at ChildProcess.<anonymous> (C:\Users\d0475\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:198:13)
13 verbose stack     at maybeClose (internal/child_process.js:982:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid flamingo-backend@1.0.0
15 verbose cwd C:\Users\d0475\Documents\Projects\flamingo-ecom2\sick-fits\backend
16 verbose Windows_NT 10.0.18362
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\d0475\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "introspect"
18 verbose node v10.16.0
19 verbose npm  v6.5.0
20 error code ELIFECYCLE
21 error errno 1
22 error flamingo-backend@1.0.0 introspect: `npx prisma introspect`
22 error Exit status 1
23 error Failed at the flamingo-backend@1.0.0 introspect script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
pantharshit00commented, Jul 15, 2020

Hello @TheoMer

You can specify the schema in database url using ?schema query parameter.

Example:

datasource db {
  provider = "postgresql"
  url      = "postgresql://myuser:mypass@somehost.com:5432/mydb?schema=my-schema$prod"
}

Let me know if this resolved the issue.

1reaction
bandlerrcommented, Nov 8, 2021

@janpio Ah yes, I see. I must’ve missed the link to the PostgreSQL-specific details at the bottom of the Connection URLs page.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prisma 1 to 2 migration issue: P4001 The introspected ...
All of my tables/data info resides in my-schema$prod . I initially presumed that I needed to change the search_path of the database to...
Read more >
What is introspection? (Reference) - Prisma
Introspection has one main function: Populate your Prisma schema with a data model that reflects the current database schema. Introspect your database with ......
Read more >
Introspect a database with Prisma (2/5) - YouTube
Website: https://www.prisma.ioQuickstart: https://www.prisma.io/docs/quickstartDocumentation: https://www.prisma.io/docs/Beta announcement: ...
Read more >
Start using Prisma in your existing database with ... - Medium
Then add below line of code. DATABASE_URL="postgresql://test:test!@localhost:5432/test. Finally, run npx prisma introspect and see the ...
Read more >
prisma-rays - npm
Error: P4001 The introspected database was empty while running rays prepare. your database is empty so it cannot be used to generate the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found