Skip to content

Commit

Permalink
Better handling of "Error: Empty introspection.." closes #1145
Browse files Browse the repository at this point in the history
  • Loading branch information
Jolg42 committed Feb 7, 2020
1 parent e211469 commit 00cdb83
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion cli/introspection/src/commands/Introspect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,17 @@ export class Introspect implements Command {
introspectionSchema = await engine.introspect(url)

if (introspectionSchema.trim() === '') {
throw new Error(`Empty introspection result for ${chalk.underline(url)}`)
throw new Error(`${chalk.red.bold('The introspected database was empty:')} ${chalk.underline(url)}
${chalk.bold('prisma2 introspect')} could not create any models in your ${chalk.bold('schema.prisma')} file and you will not be able to generate Prisma Client with the ${chalk.bold('prisma2 generate')} command.
${chalk.bold('To fix this, you have two options:')}
- manually create a table in your database (using SQL).
- make sure the database connection URL inside the ${chalk.bold('datasource')} block in ${chalk.bold('schema.prisma')} points to a database that is not empty (it must contain at least one table).
Then you can run ${chalk.green('prisma2 introspect')} again.
`)
}

const connectorType = databaseTypeToConnectorType(uriToCredentials(url).type)
Expand Down

0 comments on commit 00cdb83

Please sign in to comment.