fix export for enum and set types for mysql

This commit is contained in:
csc530 2024-10-01 21:23:45 -04:00
parent 3127d70c3a
commit 624bd1ed2c
No known key found for this signature in database

View File

@ -3,13 +3,14 @@ import { parseDefault } from "./shared";
import { dbToTypes } from "../../data/datatypes";
export function toMySQL(diagram) {
console.log(diagram)
return `${diagram.tables
.map(
(table) =>
`CREATE TABLE \`${table.name}\` (\n${table.fields
.map(
(field) =>
`\t\`${field.name}\` ${field.type}${field.unsigned ? " UNSIGNED" : ""}${field.size !== undefined && field.size !== "" ? "(" + field.size + ")" : ""}${
`\t\`${field.name}\` ${field.type}${field.values ? "(" + field.values.map(value=>"'" + value + "'").join(", ") + ")" : ""}${field.unsigned ? " UNSIGNED" : ""}${field.size !== undefined && field.size !== "" ? "(" + field.size + ")" : ""}${
field.notNull ? " NOT NULL" : ""
}${
field.increment ? " AUTO_INCREMENT" : ""