Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion drizzle-kit/src/cli/commands/generate-mssql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions drizzle-kit/src/cli/commands/push-mssql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
36 changes: 36 additions & 0 deletions drizzle-kit/src/cli/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 '';
};
Expand Down
2 changes: 1 addition & 1 deletion drizzle-kit/src/dialects/cockroach/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion drizzle-kit/src/dialects/postgres/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down