Skip to content

Commit 2bf3bd6

Browse files
rudcode1ilit
authored andcommitted
Fix postgres auto increment primary key
Add "GENERATED BY DEFAULT AS IDENTITY" if field is auto increment
1 parent c8386a0 commit 2bf3bd6

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/utils/exportSQL/postgres.js

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ export function toPostgres(diagram) {
3232
`${exportFieldComment(field.comment)}\t"${
3333
field.name
3434
}" ${field.type}${field.isArray ? " ARRAY" : ""}${field.notNull ? " NOT NULL" : ""}${field.unique ? " UNIQUE" : ""}${
35+
field.increment ? " GENERATED BY DEFAULT AS IDENTITY" : ""
36+
}${
3537
field.default.trim() !== ""
3638
? ` DEFAULT ${parseDefault(field, diagram.database)}`
3739
: ""

0 commit comments

Comments
 (0)