Skip to content

Commit

Permalink
fix: prisma2 introspect for mysql database
Browse files Browse the repository at this point in the history
  • Loading branch information
wardpeet committed Oct 7, 2019
1 parent a16d21c commit 473afd4
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions cli/introspection/src/commands/Introspect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,16 @@ ${chalk.bold('Created 1 new file:')} Prisma DML datamodel (derived from existing
)
}

// Get connector from flags
if (!credentialsByFlag.schema) {
let schema: string | undefined
if (credentialsByFlag.type === DatabaseType.mysql) {
schema = credentialsByFlag.database
}

if (credentialsByFlag.type === DatabaseType.postgres) {
schema = credentialsByFlag.schema
}

if (!schema) {
console.log(`Please provide a database name`)
return process.exit(1)
}
Expand All @@ -168,14 +176,14 @@ ${chalk.bold('Created 1 new file:')} Prisma DML datamodel (derived from existing

const schemas = await getDatabaseSchemas(connector)

assertSchemaExists(credentialsByFlag.schema, credentialsByFlag.type, schemas)
assertSchemaExists(schema, credentialsByFlag.type, schemas)

const introspectionResult = await this.introspectWithSpinner(
{
connector,
disconnect,
databaseType: credentialsByFlag.type,
databaseName: credentialsByFlag.schema,
databaseName: schema,
credentials: credentialsByFlag,
},
sdl,
Expand Down

0 comments on commit 473afd4

Please sign in to comment.