Free, simple, and intuitive online database diagram editor and SQL generator.
JavaScript databasedatabase-designdatabase-diagramdatabase-schemadbmldiagram-editoreditorer-diagramerderdiagramindexeddbmariadbmcporacle-databaseoracle-dbpostgresqlschema-designsqlsql-serversqlite
add sets
1ilit2760f458afce
diff --git a/src/components/table.jsx b/src/components/table.jsxindex 41452933..f511337e 100644--- a/src/components/table.jsx+++ b/src/components/table.jsx@@ -348,17 +348,11 @@ export default function Table(props) {(value === "INT" ||value === "BIGINT" ||value === "SMALLINT");- updateField(- props.tableData.id,- j,- value === "ENUM"- ? { type: value, enumValues: [], increment: incr }- : {- type: value,- length: value === "VARCHAR" ? 255 : "n/a",- increment: incr,- }- );+ updateField(props.tableData.id, j, {+ type: value,+ length: value === "VARCHAR" ? 255 : "n/a",+ increment: incr,+ });}}></Select></Col>@@ -450,26 +444,26 @@ export default function Table(props) {setRedoStack([]);}}/>- {f.type === "ENUM" && (+ {(f.type === "ENUM" || f.type === "SET") && (<>- <div className="font-semibold mb-1">Enum values</div>+ <div className="font-semibold mb-1">+ {f.type} values+ </div><TagInputseparator={[",", ", ", " ,"]}- value={f.enumValues}+ value={f.values}className="my-2"placeholder="Use ',' for batch input"onChange={(v) =>updateField(props.tableData.id, j, {- enumValues: v,+ values: v,})}- onFocus={(e) =>- setEditField({ enumValues: f.enumValues })- }+ onFocus={(e) => setEditField({ values: f.values })}onBlur={(e) => {if (- JSON.stringify(editField.enumValues) ===- JSON.stringify(f.enumValues)+ JSON.stringify(editField.values) ===+ JSON.stringify(f.values))return;setUndoStack((prev) => [@@ -481,7 +475,7 @@ export default function Table(props) {tid: props.tableData.id,fid: j,undo: editField,- redo: { enumValues: f.enumValues },+ redo: { values: f.values },},]);setRedoStack([]);diff --git a/src/components/table_overview.jsx b/src/components/table_overview.jsxindex 9710a4b6..31c3f07c 100644--- a/src/components/table_overview.jsx+++ b/src/components/table_overview.jsx@@ -183,17 +183,11 @@ export default function TableOverview(props) {(value === "INT" ||value === "BIGINT" ||value === "SMALLINT");- updateField(- i,- j,- value === "ENUM"- ? { type: value, enumValues: [], increment: incr }- : {- type: value,- length: value === "VARCHAR" ? 255 : "n/a",- increment: incr,- }- );+ updateField(i, j, {+ type: value,+ length: value === "VARCHAR" ? 255 : "n/a",+ increment: incr,+ });}}></Select></Col>@@ -286,26 +280,26 @@ export default function TableOverview(props) {setRedoStack([]);}}/>- {f.type === "ENUM" && (+ {(f.type === "ENUM" || f.type === "SET") && (<><div className="font-semibold mb-1">- Enum values+ {f.type} values</div><TagInputseparator={[",", ", ", " ,"]}- value={f.enumValues}+ value={f.values}className="my-2"placeholder="Use ',' for batch input"onChange={(v) =>- updateField(i, j, { enumValues: v })+ updateField(i, j, { values: v })}onFocus={(e) =>- setEditField({ enumValues: f.enumValues })+ setEditField({ values: f.values })}onBlur={(e) => {if (- JSON.stringify(editField.enumValues) ===- JSON.stringify(f.enumValues)+ JSON.stringify(editField.values) ===+ JSON.stringify(f.values))return;setUndoStack((prev) => [@@ -317,7 +311,7 @@ export default function TableOverview(props) {tid: i,fid: j,undo: editField,- redo: { enumValues: f.enumValues },+ redo: { values: f.values },},]);setRedoStack([]);diff --git a/src/data/data.js b/src/data/data.jsindex 04f3bb12..86f9facd 100644--- a/src/data/data.js+++ b/src/data/data.js@@ -20,6 +20,7 @@ const sqlDataTypes = ["BLOB","JSON","ENUM",+ "SET",];const tableThemes = [diff --git a/src/schemas/index.js b/src/schemas/index.jsindex 2d0c1174..46a639cd 100644--- a/src/schemas/index.js+++ b/src/schemas/index.js@@ -19,6 +19,8 @@ const tableSchema = {notNull: { type: "boolean" },increment: { type: "boolean" },comment: { type: "string" },+ length: { type: ["string", "number"] },+ values: { type: "array", items: { type: "string" } },},required: ["name",@@ -30,6 +32,7 @@ const tableSchema = {"notNull","increment","comment",+ "length",],},},@@ -86,69 +89,7 @@ const jsonSchema = {properties: {tables: {type: "array",- items: {- type: "object",- properties: {- id: { type: "integer" },- name: { type: "string" },- x: { type: "number" },- y: { type: "number" },- fields: {- type: "array",- items: {- type: "object",- properties: {- name: { type: "string" },- type: { type: "string" },- default: { type: "string" },- check: { type: "string" },- primary: { type: "boolean" },- unique: { type: "boolean" },- notNull: { type: "boolean" },- increment: { type: "boolean" },- comment: { type: "string" },- },- required: [- "name",- "type",- "default",- "check",- "primary",- "unique",- "notNull",- "increment",- "comment",- ],- },- },- comment: { type: "string" },- indices: {- type: "array",- items: {- type: "object",- properties: {- name: { type: "string" },- fields: {- type: "array",- items: { type: "string" },- },- },- required: ["name", "fields"],- },- },- color: { type: "string", pattern: "^#[0-9a-fA-F]{6}$" },- },- required: [- "id",- "name",- "x",- "y",- "fields",- "comment",- "indices",- "color",- ],- },+ items: { ...tableSchema },},relationships: {type: "array",@@ -190,35 +131,11 @@ const jsonSchema = {},notes: {type: "array",- items: {- type: "object",- properties: {- id: { type: "integer" },- x: { type: "number" },- y: { type: "number" },- title: { type: "string" },- content: { type: "string" },- color: { type: "string", pattern: "^#[0-9a-fA-F]{6}$" },- height: { type: "number" },- },- required: ["id", "x", "y", "title", "content", "color", "height"],- },+ items: { ...noteSchema },},subjectAreas: {type: "array",- items: {- type: "object",- properties: {- id: { type: "integer" },- name: { type: "string" },- x: { type: "number" },- y: { type: "number" },- width: { type: "number" },- height: { type: "number" },- color: { type: "string", pattern: "^#[0-9a-fA-F]{6}$" },- },- required: ["id", "name", "x", "y", "width", "height", "color"],- },+ items: { ...areaSchema },},},required: ["tables", "relationships", "notes", "subjectAreas"],diff --git a/src/utils/index.js b/src/utils/index.jsindex e15062ab..dcc70c79 100644--- a/src/utils/index.js+++ b/src/utils/index.js@@ -61,8 +61,8 @@ function jsonToSQL(obj) {}\` ${field.type}${field.length !== "n/a"? `(${field.length})`- : field.enumValues- ? `(${field.enumValues.map((v) => `"${v}"`).join(", ")})`+ : field.type === "ENUM" || field.type === "SET"+ ? `(${field.values.map((v) => `"${v}"`).join(", ")})`: ""}${field.notNull ? " NOT NULL" : ""}${field.increment ? " AUTO_INCREMENT" : ""