Skip to content

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

Use unsigned keyword only if type is signed (#528)

1ilit24d56cc7bf48
diff --git a/src/utils/exportSQL/mysql.js b/src/utils/exportSQL/mysql.js
index 6d9d4fb0..a835778e 100644
--- a/src/utils/exportSQL/mysql.js
+++ b/src/utils/exportSQL/mysql.js
@@ -27,9 +27,11 @@ export function toMySQL(diagram) {
`CREATE TABLE \`${table.name}\` (\n${table.fields
.map(
(field) =>
- `\t\`${field.name}\` ${parseType(field)}${field.unsigned ? " UNSIGNED" : ""}${
- field.notNull ? " NOT NULL" : ""
- }${
+ `\t\`${field.name}\` ${parseType(field)}${
+ dbToTypes[DB.MYSQL][field.type]?.signed && field.unsigned
+ ? " UNSIGNED"
+ : ""
+ }${field.notNull ? " NOT NULL" : ""}${
field.increment ? " AUTO_INCREMENT" : ""
}${field.unique ? " UNIQUE" : ""}${
field.default !== ""