Skip to content

Commit

Permalink
fix: mark primary key auto-increment only if column type is TINYINT S…
Browse files Browse the repository at this point in the history
…MALLINT MEDIUMINT INT BIGINT

Signed-off-by: Muhammad Aaqil <[email protected]>
  • Loading branch information
aaqilniz authored and dhmlau committed Aug 14, 2024
1 parent b0a5ccc commit b657e73
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit b657e73

Please sign in to comment.