fix: mark primary key auto-increment only if column type is TINYINT SMALLINT MEDIUMINT INT BIGINT

Signed-off-by: Muhammad Aaqil <aaqilcs102@gmail.com>
This commit is contained in:
Muhammad Aaqil 2024-06-25 22:51:50 +05:00 committed by Diana Lau
parent b0a5ccc677
commit b657e73ede
1 changed files with 7 additions and 1 deletions

View File

@ -628,7 +628,13 @@ function mixinMigration(MySQL, mysql) {
if (pks.length === 1) {
const idName = this.idName(model);
const idProp = this.getModelDefinition(model).properties[idName];
if (idProp.generated) {
const idColumnType = this.columnDataType(model, idName);
if (idProp.generated && (
idColumnType === 'TINYINT' ||
idColumnType === 'SMALLINT' ||
idColumnType === 'MEDIUMINT' ||
idColumnType === 'INT' ||
idColumnType === 'BIGINT')) {
sql.push(self.columnEscaped(model, idName) + ' ' +
self.buildColumnDefinition(model, idName) + ' AUTO_INCREMENT PRIMARY KEY');
} else {