Skip to content

Free, simple, and intuitive online database diagram editor and SQL generator.

Fix postgres auto increment primary key

Rudy Nurhadi2bf3bd6ec1ba
diff --git a/src/utils/exportSQL/postgres.js b/src/utils/exportSQL/postgres.js
index 0db0e52a..bccd4a84 100644
--- a/src/utils/exportSQL/postgres.js
+++ b/src/utils/exportSQL/postgres.js
@@ -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)}`
: ""