Fix postgres auto increment primary key

Add "GENERATED BY DEFAULT AS IDENTITY" if field is auto increment
This commit is contained in:
Rudy Nurhadi 2024-10-08 06:17:29 +07:00
parent b56024bc83
commit c78245cb3a

View File

@ -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)}`
: ""