fix(database): id is not generated when custom primary key

This commit is contained in:
chenos 2022-12-01 10:00:46 +08:00
parent 34c9ec123e
commit 1f431dc2d6

View File

@ -7,7 +7,7 @@ import {
QueryInterfaceDropTableOptions,
SyncOptions,
Transactionable,
Utils,
Utils
} from 'sequelize';
import { Database } from './database';
import { Field, FieldOptions } from './fields';
@ -200,6 +200,10 @@ export class Collection<
);
}
if (this.options.autoGenId !== false && options.primaryKey) {
this.model.removeAttribute('id');
}
this.removeField(name);
this.fields.set(name, field);
this.emit('field.afterAdd', field);