Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/auto-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,7 @@ export class AutoGenerator {
if (this.dialect.name === "mssql" && (["(NULL)", "NULL"].includes(defaultVal) || typeof defaultVal === "undefined")) {
defaultVal = null as any; // Override default NULL in MS SQL to javascript null
}

if (defaultVal === null || defaultVal === undefined) {
if ((defaultVal === null || defaultVal === undefined) && !fieldObj.primaryKey) {
return true;
}
if (isSerialKey) {
Expand Down Expand Up @@ -396,6 +395,9 @@ export class AutoGenerator {
// don't prepend N for MSSQL when building models...
// defaultVal = _.trimStart(defaultVal, 'N');

if (fieldObj.primaryKey){
val_text = "DataTypes.UUIDV4";
}
str += space[3] + attr + ": " + val_text;

} else if (attr === "comment" && (!fieldObj[attr] || this.dialect.name === "mssql")) {
Expand Down Expand Up @@ -473,6 +475,9 @@ export class AutoGenerator {
/** Get the sequelize type from the Field */
private getSqType(fieldObj: Field, attr: string): string {
const attrValue = (fieldObj as any)[attr];
if (fieldObj.primaryKey) {
return "DataTypes.UUID";
}
if (!attrValue.toLowerCase) {
console.log("attrValue", attr, attrValue);
return attrValue;
Expand Down