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 and primary key
  • Loading branch information
rudcode committed Oct 8, 2024
1 parent b56024b commit 63c840a
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 63c840a

Please sign in to comment.