Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
fix: export names of default constraints
Browse files Browse the repository at this point in the history
Closes #81
  • Loading branch information
lmeyer1 authored and justinlettau committed Sep 9, 2019
1 parent de2d68f commit 47eb83c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/generators/mssql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,9 @@ export default class MSSQLGenerator {
output += item.is_nullable ? ' NULL' : ' NOT NULL';

if (item.definition) {
if (item.default_name) {
output += ` CONSTRAINT [${item.default_name}]`;
}
output += ` DEFAULT${item.definition}`;
}

Expand Down
1 change: 1 addition & 0 deletions src/queries/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export interface SqlColumn {
seed_value: number;
increment_value: number;
formula: string;
default_name: string;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/queries/mssql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ export const columnsRead = `
ic.is_identity,
ic.seed_value,
ic.increment_value,
cc.definition AS [formula]
cc.definition AS [formula],
dc.name as default_name
FROM
sys.columns c
JOIN sys.types tp ON c.user_type_id = tp.user_type_id
Expand Down

0 comments on commit 47eb83c

Please sign in to comment.