Skip to content

Commit

Permalink
Fix postgres auto increment primary key
Browse files Browse the repository at this point in the history
Add "GENERATED BY DEFAULT AS IDENTITY" if field is auto increment
  • Loading branch information
rudcode authored and 1ilit committed Oct 11, 2024
1 parent c8386a0 commit 2bf3bd6
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/utils/exportSQL/postgres.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export function toPostgres(diagram) {
`${exportFieldComment(field.comment)}\t"${
field.name
}" ${field.type}${field.isArray ? " ARRAY" : ""}${field.notNull ? " NOT NULL" : ""}${field.unique ? " UNIQUE" : ""}${
field.increment ? " GENERATED BY DEFAULT AS IDENTITY" : ""
}${
field.default.trim() !== ""
? ` DEFAULT ${parseDefault(field, diagram.database)}`
: ""
Expand Down

0 comments on commit 2bf3bd6

Please sign in to comment.