'NPM TypeORM - "Error: Duplicate migrations" after modifying/deleting migration file
I previously add a column to an existing table using, npm run migration:generate <filename>
.
However, I later realized that I misspelled the column name so I wanted to rename the column. (showComission -> showCommission)
Since it was just in a local environment, I modified the column name on the migration file and run npm run migration:run
.
The duplicated migration error occurred and here's the log.
**addShowCommissionToCorporationProfile1643792138368 is the modified export class name.
typeorm migration:run
query: SELECT * FROM
INFORMATION_SCHEMA
.COLUMNS
WHERETABLE_SCHEMA
= 'abc' ANDTABLE_NAME
= 'migrations'query: SELECT * FROM
abc
.migrations
migrations
ORDER BYid
DESCError during migration run:
Error: Duplicate migrations: addShowCommissionToCorporationProfile1643792138368at MigrationExecutor.checkForDuplicateMigrations at MigrationExecutor.getMigrations at MigrationExecutor.<anonymous> at step at Object.next at fulfilled at processTicksAndRejections npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] migration:run: `typeorm migration:run`
npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] migration:run script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
After that I try to revert npm run migration:revert
, but the exact same error occurred. So instead, I changed the migration file back to its initial state and use npm run migration:generate --filename
to create migration file for renaming the column but the same error stills occurred.
Lastly, I deleted newly created migration file and run only the original migration file (initial state) and run migration again, but the same error stills occurred.
Can anyone advise me how could I fixed this mess?
I just wanted to rename the column...
Please let me know if you need any additional info or more clarification about the situation.
Appreciate all your helps.
Solution 1:[1]
I exec npm run build and the problem solved.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Emilio Tonso |