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 committed Jul 6, 2024
1 parent 55ef653 commit 2d04a1a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,17 @@ 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 &&

Check failure on line 633 in lib/migration.js

View workflow job for this annotation

GitHub Actions / build (18)

Trailing spaces not allowed

Check failure on line 633 in lib/migration.js

View workflow job for this annotation

GitHub Actions / build (20)

Trailing spaces not allowed

Check failure on line 633 in lib/migration.js

View workflow job for this annotation

GitHub Actions / Code Lint

Trailing spaces not allowed
(
idColumnType === 'TINYINT' ||
idColumnType === 'SMALLINT' ||
idColumnType === 'MEDIUMINT' ||
idColumnType === 'INT' ||
idColumnType === 'BIGINT'
)
) {

Check failure on line 641 in lib/migration.js

View workflow job for this annotation

GitHub Actions / build (18)

Expected indentation of 8 spaces but found 10

Check failure on line 641 in lib/migration.js

View workflow job for this annotation

GitHub Actions / build (20)

Expected indentation of 8 spaces but found 10

Check failure on line 641 in lib/migration.js

View workflow job for this annotation

GitHub Actions / Code Lint

Expected indentation of 8 spaces but found 10
sql.push(self.columnEscaped(model, idName) + ' ' +
self.buildColumnDefinition(model, idName) + ' AUTO_INCREMENT PRIMARY KEY');
} else {
Expand Down

0 comments on commit 2d04a1a

Please sign in to comment.