Remove unnecessary commas in export index statements
This commit is contained in:
parent
159dcca4dc
commit
6fee6553f1
@ -174,18 +174,14 @@ export function jsonToMySQL(obj) {
|
||||
.map((f) => `\`${f.name}\``)
|
||||
.join(", ")})`
|
||||
: ""
|
||||
}\n)${table.comment ? ` COMMENT='${table.comment}'` : ""};\n${
|
||||
table.indices.length > 0
|
||||
? `\n${table.indices
|
||||
.map(
|
||||
(i) =>
|
||||
`CREATE ${i.unique ? "UNIQUE " : ""}INDEX \`${i.name}\`\nON \`${table.name}\` (${i.fields
|
||||
.map((f) => `\`${f}\``)
|
||||
.join(", ")});`,
|
||||
)
|
||||
.join("\n")}`
|
||||
: ""
|
||||
}`,
|
||||
}\n)${table.comment ? ` COMMENT='${table.comment}'` : ""};\n${`\n${table.indices
|
||||
.map(
|
||||
(i) =>
|
||||
`CREATE ${i.unique ? "UNIQUE " : ""}INDEX \`${i.name}\`\nON \`${table.name}\` (${i.fields
|
||||
.map((f) => `\`${f}\``)
|
||||
.join(", ")});`,
|
||||
)
|
||||
.join("\n")}`}`,
|
||||
)
|
||||
.join("\n")}\n${obj.references
|
||||
.map(
|
||||
@ -267,20 +263,16 @@ export function jsonToPostgreSQL(obj) {
|
||||
.map((f) => `"${f.name}"`)
|
||||
.join(", ")})`
|
||||
: ""
|
||||
}\n);\n${
|
||||
table.indices.length > 0
|
||||
? `${table.indices
|
||||
.map(
|
||||
(i) =>
|
||||
`CREATE ${i.unique ? "UNIQUE " : ""}INDEX "${
|
||||
i.name
|
||||
}"\nON "${table.name}" (${i.fields
|
||||
.map((f) => `"${f}"`)
|
||||
.join(", ")});`,
|
||||
)
|
||||
.join("\n")}`
|
||||
: ""
|
||||
}`,
|
||||
}\n);\n${table.indices
|
||||
.map(
|
||||
(i) =>
|
||||
`CREATE ${i.unique ? "UNIQUE " : ""}INDEX "${
|
||||
i.name
|
||||
}"\nON "${table.name}" (${i.fields
|
||||
.map((f) => `"${f}"`)
|
||||
.join(", ")});`,
|
||||
)
|
||||
.join("\n")}`,
|
||||
)
|
||||
.join("\n")}\n${obj.references
|
||||
.map(
|
||||
@ -369,20 +361,16 @@ export function jsonToSQLite(obj) {
|
||||
.map((f) => `"${f.name}"`)
|
||||
.join(", ")})${inlineFK !== "" ? ",\n" : ""}`
|
||||
: ""
|
||||
}\t${inlineFK}\n);\n${
|
||||
table.indices.length > 0
|
||||
? `${table.indices
|
||||
.map(
|
||||
(i) =>
|
||||
`\nCREATE ${i.unique ? "UNIQUE " : ""}INDEX IF NOT EXISTS "${
|
||||
i.name
|
||||
}"\nON "${table.name}" (${i.fields
|
||||
.map((f) => `"${f}"`)
|
||||
.join(", ")});`,
|
||||
)
|
||||
.join("\n")}`
|
||||
: ""
|
||||
}`;
|
||||
}\t${inlineFK}\n);\n${table.indices
|
||||
.map(
|
||||
(i) =>
|
||||
`\nCREATE ${i.unique ? "UNIQUE " : ""}INDEX IF NOT EXISTS "${
|
||||
i.name
|
||||
}"\nON "${table.name}" (${i.fields
|
||||
.map((f) => `"${f}"`)
|
||||
.join(", ")});`,
|
||||
)
|
||||
.join("\n")}`;
|
||||
})
|
||||
.join("\n");
|
||||
}
|
||||
@ -424,20 +412,16 @@ export function jsonToMariaDB(obj) {
|
||||
.map((f) => `\`${f.name}\``)
|
||||
.join(", ")})`
|
||||
: ""
|
||||
}\n);${
|
||||
table.indices.length > 0
|
||||
? `\n${table.indices
|
||||
.map(
|
||||
(i) =>
|
||||
`CREATE ${i.unique ? "UNIQUE " : ""}INDEX \`${
|
||||
i.name
|
||||
}\`\nON \`${table.name}\` (${i.fields
|
||||
.map((f) => `\`${f}\``)
|
||||
.join(", ")});`,
|
||||
)
|
||||
.join("\n")}`
|
||||
: ""
|
||||
}`,
|
||||
}\n);${`\n${table.indices
|
||||
.map(
|
||||
(i) =>
|
||||
`CREATE ${i.unique ? "UNIQUE " : ""}INDEX \`${
|
||||
i.name
|
||||
}\`\nON \`${table.name}\` (${i.fields
|
||||
.map((f) => `\`${f}\``)
|
||||
.join(", ")});`,
|
||||
)
|
||||
.join("\n")}`}`,
|
||||
)
|
||||
.join("\n")}\n${obj.references
|
||||
.map(
|
||||
@ -496,18 +480,16 @@ export function jsonToSQLServer(obj) {
|
||||
.map((f) => `[${f.name}]`)
|
||||
.join(", ")})`
|
||||
: ""
|
||||
}\n);\nGO\n${
|
||||
table.indices.length > 0
|
||||
? `${table.indices.map(
|
||||
(i) =>
|
||||
`\nCREATE ${i.unique ? "UNIQUE " : ""}INDEX [${
|
||||
i.name
|
||||
}]\nON [${table.name}] (${i.fields
|
||||
.map((f) => `[${f}]`)
|
||||
.join(", ")});\nGO\n`,
|
||||
)}`
|
||||
: ""
|
||||
}`,
|
||||
}\n);\nGO\n${table.indices
|
||||
.map(
|
||||
(i) =>
|
||||
`\nCREATE ${i.unique ? "UNIQUE " : ""}INDEX [${
|
||||
i.name
|
||||
}]\nON [${table.name}] (${i.fields
|
||||
.map((f) => `[${f}]`)
|
||||
.join(", ")});\nGO\n`,
|
||||
)
|
||||
.join("")}`,
|
||||
)
|
||||
.join("\n")}\n${obj.references
|
||||
.map(
|
||||
|
@ -32,18 +32,16 @@ export function toMariaDB(diagram) {
|
||||
.map((f) => `\`${f.name}\``)
|
||||
.join(", ")})`
|
||||
: ""
|
||||
}\n);${
|
||||
table.indices.length > 0
|
||||
? `\n${table.indices.map(
|
||||
(i) =>
|
||||
`\nCREATE ${i.unique ? "UNIQUE " : ""}INDEX \`${
|
||||
i.name
|
||||
}\`\nON \`${table.name}\` (${i.fields
|
||||
.map((f) => `\`${f}\``)
|
||||
.join(", ")});`,
|
||||
)}`
|
||||
: ""
|
||||
}`,
|
||||
}\n);${`\n${table.indices
|
||||
.map(
|
||||
(i) =>
|
||||
`\nCREATE ${i.unique ? "UNIQUE " : ""}INDEX \`${
|
||||
i.name
|
||||
}\`\nON \`${table.name}\` (${i.fields
|
||||
.map((f) => `\`${f}\``)
|
||||
.join(", ")});`,
|
||||
)
|
||||
.join("")}`}`,
|
||||
)
|
||||
.join("\n")}\n${diagram.references
|
||||
.map(
|
||||
|
@ -32,18 +32,16 @@ export function toMySQL(diagram) {
|
||||
.map((f) => `\`${f.name}\``)
|
||||
.join(", ")})`
|
||||
: ""
|
||||
}\n)${table.comment ? ` COMMENT='${table.comment}'` : ""};\n${
|
||||
table.indices.length > 0
|
||||
? `\n${table.indices.map(
|
||||
(i) =>
|
||||
`\nCREATE ${i.unique ? "UNIQUE " : ""}INDEX \`${
|
||||
i.name
|
||||
}\`\nON \`${table.name}\` (${i.fields
|
||||
.map((f) => `\`${f}\``)
|
||||
.join(", ")});`,
|
||||
)}`
|
||||
: ""
|
||||
}`,
|
||||
}\n)${table.comment ? ` COMMENT='${table.comment}'` : ""};\n${`\n${table.indices
|
||||
.map(
|
||||
(i) =>
|
||||
`\nCREATE ${i.unique ? "UNIQUE " : ""}INDEX \`${
|
||||
i.name
|
||||
}\`\nON \`${table.name}\` (${i.fields
|
||||
.map((f) => `\`${f}\``)
|
||||
.join(", ")});`,
|
||||
)
|
||||
.join("")}`}`,
|
||||
)
|
||||
.join("\n")}\n${diagram.references
|
||||
.map(
|
||||
|
@ -12,17 +12,17 @@ export function toPostgres(diagram) {
|
||||
const typeStatements = diagram.types
|
||||
.map(
|
||||
(type) =>
|
||||
`CREATE TYPE ${type.name} AS (\n${type.fields
|
||||
`\nCREATE TYPE ${type.name} AS (\n${type.fields
|
||||
.map((f) => `\t${f.name} ${f.type}`)
|
||||
.join("\n")}\n);\n${
|
||||
.join("\n")}\n);\n\n${
|
||||
type.comment.trim() !== ""
|
||||
? `\nCOMMENT ON TYPE "${type.name}" IS '${type.comment}';\n`
|
||||
? `\nCOMMENT ON TYPE "${type.name}" IS '${type.comment}';\n\n`
|
||||
: ""
|
||||
}`,
|
||||
)
|
||||
.join("\n");
|
||||
|
||||
return `${enumStatements}\n\n${typeStatements}\n${diagram.tables
|
||||
return `${enumStatements}${typeStatements}${diagram.tables
|
||||
.map(
|
||||
(table) =>
|
||||
`CREATE TABLE "${table.name}" (\n${table.fields
|
||||
|
@ -28,20 +28,16 @@ export function toSqlite(diagram) {
|
||||
.map((f) => `"${f.name}"`)
|
||||
.join(", ")})${inlineFK !== "" ? ",\n" : ""}`
|
||||
: ""
|
||||
}\t${inlineFK}\n);\n${
|
||||
table.indices.length > 0
|
||||
? `${table.indices
|
||||
.map(
|
||||
(i) =>
|
||||
`\nCREATE ${i.unique ? "UNIQUE " : ""}INDEX IF NOT EXISTS "${
|
||||
i.name
|
||||
}"\nON "${table.name}" (${i.fields
|
||||
.map((f) => `"${f}"`)
|
||||
.join(", ")});`,
|
||||
)
|
||||
.join("\n")}`
|
||||
: ""
|
||||
}`;
|
||||
}\t${inlineFK}\n);\n${table.indices
|
||||
.map(
|
||||
(i) =>
|
||||
`\nCREATE ${i.unique ? "UNIQUE " : ""}INDEX IF NOT EXISTS "${
|
||||
i.name
|
||||
}"\nON "${table.name}" (${i.fields
|
||||
.map((f) => `"${f}"`)
|
||||
.join(", ")});`,
|
||||
)
|
||||
.join("\n")}`;
|
||||
})
|
||||
.join("\n");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user