Skip to content

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

Merge branch 'main' into select-db

1ilit322bb6e9888d
diff --cc src/components/EditorSidePanel/TablesTab/IndexDetails.jsx
index 243e1677,1af09c29..3bc4dfb3
--- a/src/components/EditorSidePanel/TablesTab/IndexDetails.jsx
+++ b/src/components/EditorSidePanel/TablesTab/IndexDetails.jsx
@@@ -1,13 -1,15 +1,15 @@@
import { Action, ObjectType } from "../../../data/constants";
import { Input, Button, Popover, Checkbox, Select } from "@douyinfe/semi-ui";
import { IconMore, IconDeleteStroked } from "@douyinfe/semi-icons";
-import { useTables, useUndoRedo } from "../../../hooks";
+import { useDiagram, useUndoRedo } from "../../../hooks";
import { useTranslation } from "react-i18next";
+ import { useState } from "react";
export default function IndexDetails({ data, fields, iid, tid }) {
const { t } = useTranslation();
- const { tables, updateTable } = useTables();
+ const { tables, updateTable } = useDiagram();
const { setUndoStack, setRedoStack } = useUndoRedo();
+ const [editField, setEditField] = useState({});
return (
<div className="flex justify-between items-center mb-2">
@@@ -133,7 -173,7 +173,7 @@@
});
}}
>
-- Delete
++ {t("delete")}
</Button>
</div>
}
diff --cc src/i18n/locales/en.js
index 2a438a43,1359a983..11acde0e
--- a/src/i18n/locales/en.js
+++ b/src/i18n/locales/en.js
@@@ -212,20 -212,7 +212,21 @@@ const en =
edit_relationship: "{{extra}} Edit relationship {{refName}}",
delete_relationship: "Delete relationship {{refName}}",
not_found: "Not found",
+ pick_db: "Choose a database",
+ generic: "Generic",
+ generic_description:
+ "Generic diagrams can be exported to any SQL flavor but support few data types.",
+ enums: "Enums",
+ add_enum: "Add enum",
+ edit_enum: "{{extra}} Edit enum {{enumName}}",
+ delete_enum: "Delete enum",
+ enum_w_no_name: "Found enum with no name",
+ enum_w_no_values: "Found enum '{{enumName}}' with no values",
+ duplicate_enums: "Duplicate enums with the name '{{enumName}}'",
+ no_enums: "No enums",
+ no_enums_text: "Define enums here",
+ declare_array: "Declare array",
+ empty_index_name: "Declared an index with no name in table '{{tableName}}'",
},
};
diff --cc src/utils/exportSQL/generic.js
index 86631401,9f1fa30e..16427bc6
--- a/src/utils/exportSQL/generic.js
+++ b/src/utils/exportSQL/generic.js
@@@ -249,15 -263,12 +249,13 @@@ export function jsonToPostgreSQL(obj)
(field) =>
`${field.comment === "" ? "" : `\t-- ${field.comment}\n`}\t"${
field.name
- }" ${getTypeString(field, "postgres")}${
+ }" ${getTypeString(field, obj.database, "postgres")}${
field.notNull ? " NOT NULL" : ""
- }${
- field.default !== ""
- ? ` DEFAULT ${parseDefault(field, obj.database)}`
- : ""
+ }${field.unique ? " UNIQUE" : ""}${
+ field.default !== "" ? ` DEFAULT ${parseDefault(field)}` : ""
}${
- field.check === "" || !hasCheck(field.type)
+ field.check === "" ||
+ !dbToTypes[obj.database][field.type].hasCheck
? ""
: ` CHECK(${field.check})`
}`,