Free, simple, and intuitive online database diagram editor and SQL generator.
JavaScript databasedatabase-designdatabase-diagramdatabase-schemadbmldiagram-editoreditorer-diagramerderdiagramindexeddbmariadbmcporacle-databaseoracle-dbpostgresqlschema-designsqlsql-serversqlite
Parse types for postgres
1ilit6172d48bf598
diff --git a/src/components/control_panel.jsx b/src/components/control_panel.jsxindex 64bc49f6..d1a507bb 100644--- a/src/components/control_panel.jsx+++ b/src/components/control_panel.jsx@@ -775,7 +775,7 @@ export default function ControlPanel(props) {relationships: relationships,notes: notes,subjectAreas: areas,- types: types+ types: types,},null,2@@ -797,6 +797,7 @@ export default function ControlPanel(props) {const src = jsonToMySQL({tables: tables,references: relationships,+ types: types,});setExportData((prev) => ({...prev,@@ -811,6 +812,7 @@ export default function ControlPanel(props) {const src = jsonToPostgreSQL({tables: tables,references: relationships,+ types: types,});setExportData((prev) => ({...prev,diff --git a/src/utils/index.js b/src/utils/index.jsindex 6706ee7d..e9119cf1 100644--- a/src/utils/index.js+++ b/src/utils/index.js@@ -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`}${