diff --git a/packages/drizzle/src/utilities/createSchemaGenerator.ts b/packages/drizzle/src/utilities/createSchemaGenerator.ts index 846b4dc1cec..f8f458abf3b 100644 --- a/packages/drizzle/src/utilities/createSchemaGenerator.ts +++ b/packages/drizzle/src/utilities/createSchemaGenerator.ts @@ -56,6 +56,13 @@ const renameTypescriptVariables = (source: string, variablesMap: Map { let formatted = '' @@ -138,6 +145,12 @@ declare module "${packageName}/types" { ) } +/** + * * Returns method that uses Drizzle CLI pull command to generate output schema. + * * Builds dynamically needed for CLI config https://orm.drizzle.team/docs/drizzle-config-file + * * Uses temporary directory for calling the CLI. + * * Saves the final output, either to defaultOutputFile or current working directory. + */ export const createSchemaGenerator = ({ dbCredentials, defaultOutputFile, @@ -188,16 +201,9 @@ ${Object.entries(dbCredentials) await writeFile(drizzleConfigPath, drizzleConfig, 'utf-8') - try { - execSync(`node ${drizzleBinPath} pull --config=${drizzleConfigPath}`, { - stdio: 'inherit', - }) - } catch (e) { - this.payload.logger.error(e) - throw e - } - - this.payload.logger.info('Post processing...') + execSync(`node ${drizzleBinPath} pull --config=${drizzleConfigPath}`, { + stdio: 'inherit', + }) const [schema] = await Promise.all([ readFile(path.resolve(tempDir, 'schema.ts'), 'utf-8'),