From c78245cb3ac45647d15b533a9f263a631b58fa27 Mon Sep 17 00:00:00 2001 From: Rudy Nurhadi Date: Tue, 8 Oct 2024 06:17:29 +0700 Subject: [PATCH] Fix postgres auto increment primary key Add "GENERATED BY DEFAULT AS IDENTITY" if field is auto increment --- src/utils/exportSQL/postgres.js | 2 ++ 1 file changed, 2 insertions(+) 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)}` : ""