diff --git a/drizzle-kit/src/cli/commands/generate-mssql.ts b/drizzle-kit/src/cli/commands/generate-mssql.ts index 45441df00..4e6138977 100644 --- a/drizzle-kit/src/cli/commands/generate-mssql.ts +++ b/drizzle-kit/src/cli/commands/generate-mssql.ts @@ -101,7 +101,7 @@ export const handleExport = async (config: ExportConfig) => { const { ddl, errors: errors2 } = interimToDDL(schema); if (errors2.length > 0) { - console.log(errors.map((it) => mssqlSchemaError(it)).join('\n')); + console.log(errors2.map((it) => mssqlSchemaError(it)).join('\n')); process.exit(1); } diff --git a/drizzle-kit/src/cli/commands/push-mssql.ts b/drizzle-kit/src/cli/commands/push-mssql.ts index 62b405fa8..8090e1e74 100644 --- a/drizzle-kit/src/cli/commands/push-mssql.ts +++ b/drizzle-kit/src/cli/commands/push-mssql.ts @@ -67,12 +67,12 @@ export const handle = async ( const { ddl: ddl2, errors: errors2 } = interimToDDL(schemaTo); if (errors1.length > 0) { - console.log(errors.map((it) => mssqlSchemaError(it)).join('\n')); + console.log(errors1.map((it) => mssqlSchemaError(it)).join('\n')); process.exit(1); } if (errors2.length > 0) { - console.log(errors.map((it) => mssqlSchemaError(it)).join('\n')); + console.log(errors2.map((it) => mssqlSchemaError(it)).join('\n')); process.exit(1); } diff --git a/drizzle-kit/src/cli/views.ts b/drizzle-kit/src/cli/views.ts index 799ed28e9..407d694a2 100644 --- a/drizzle-kit/src/cli/views.ts +++ b/drizzle-kit/src/cli/views.ts @@ -923,6 +923,42 @@ export const postgresSchemaError = (error: PostgresSchemaError): string => { return withStyle.errorWarning(`There's a sequence name duplicate '${error.name}' in '${error.schema}' schema`); } + if (error.type === 'table_name_duplicate') { + const { schema, name } = error; + return withStyle.errorWarning( + `There's a duplicate table name '${name}' in '${schema}' schema. This can happen if you export the same table under multiple names.`, + ); + } + + if (error.type === 'column_name_duplicate') { + const { schema, table, name } = error; + return withStyle.errorWarning( + `There's a duplicate column name '${name}' in '${schema}.${table}' table.`, + ); + } + + if (error.type === 'schema_name_duplicate') { + return withStyle.errorWarning(`There's a duplicate schema name '${error.name}'.`); + } + + if (error.type === 'enum_name_duplicate') { + const { schema, name } = error; + return withStyle.errorWarning(`There's a duplicate enum name '${name}' in '${schema}' schema.`); + } + + if (error.type === 'enum_values_duplicate') { + const { schema, name } = error; + return withStyle.errorWarning(`There are duplicate values in enum '${name}' in '${schema}' schema.`); + } + + if (error.type === 'role_duplicate') { + return withStyle.errorWarning(`There's a duplicate role name '${error.name}'.`); + } + + if (error.type === 'privilege_duplicate') { + return withStyle.errorWarning(`There's a duplicate privilege '${error.name}'.`); + } + // assertUnreachable(error); return ''; }; diff --git a/drizzle-kit/src/dialects/cockroach/serializer.ts b/drizzle-kit/src/dialects/cockroach/serializer.ts index b4465e8c0..8c62079e6 100644 --- a/drizzle-kit/src/dialects/cockroach/serializer.ts +++ b/drizzle-kit/src/dialects/cockroach/serializer.ts @@ -49,7 +49,7 @@ export const prepareSnapshot = async ( const { ddl: ddlCur, errors: errors2 } = interimToDDL(schema); if (errors2.length > 0) { - console.log(errors.map((it) => postgresSchemaError(it)).join('\n')); + console.log(errors2.map((it) => postgresSchemaError(it)).join('\n')); process.exit(1); } diff --git a/drizzle-kit/src/dialects/postgres/serializer.ts b/drizzle-kit/src/dialects/postgres/serializer.ts index fe5ee11c1..0b021c2c3 100644 --- a/drizzle-kit/src/dialects/postgres/serializer.ts +++ b/drizzle-kit/src/dialects/postgres/serializer.ts @@ -49,7 +49,7 @@ export const prepareSnapshot = async ( const { ddl: ddlCur, errors: errors2 } = interimToDDL(schema); if (errors2.length > 0) { - console.log(errors.map((it) => postgresSchemaError(it)).join('\n')); + console.log(errors2.map((it) => postgresSchemaError(it)).join('\n')); process.exit(1); }