mirror of
https://github.com/drawdb-io/drawdb.git
synced 2026-02-11 02:00:37 +08:00
Parse types for postgres
This commit is contained in:
@@ -177,7 +177,19 @@ function jsonToMySQL(obj) {
|
||||
}
|
||||
|
||||
function jsonToPostgreSQL(obj) {
|
||||
return `${obj.tables
|
||||
return `${obj.types.map(
|
||||
(type) =>
|
||||
`${type.fields
|
||||
.filter((f) => f.type === "ENUM" || f.type === "SET")
|
||||
.map(
|
||||
(f) =>
|
||||
`CREATE TYPE "${f.name}_t" AS ENUM (${f.values
|
||||
.map((v) => `'${v}'`)
|
||||
.join(", ")});\n`
|
||||
)}CREATE TYPE ${type.name} AS (\n${type.fields
|
||||
.map((f) => `\t${f.name} ${getTypeString(f, "postgres")}`)
|
||||
.join("\n")}\n);`
|
||||
)}\n${obj.tables
|
||||
.map(
|
||||
(table) =>
|
||||
`${table.comment === "" ? "" : `/**\n${table.comment}\n*/\n`}${
|
||||
|
||||
Reference in New Issue
Block a user