Recently, I made a modification to an existing table by adding a new column using the command
npm run migration:generate <filename>
.
Unfortunately, I realized later on that I had misspelled the column name and needed to correct it (showComission -> showCommission).
Since this was only in my local environment, I went ahead and updated the column name in the migration file and executed the command npm run migration:run
.
However, I encountered a duplicated migration error, which led me to check the log where I found the message concerning the modified export class name as **addShowCommissionToCorporationProfile1643792138368.
The following steps were taken:
- typeorm migration:run
- query: SELECT * FROM
INFORMATION_SCHEMA
.COLUMNS
WHERETABLE_SCHEMA
= 'abc' ANDTABLE_NAME
= 'migrations'- query: SELECT * FROM
abc
.migrations
migrations
ORDER BYid
DESCFurther along, I encountered an error 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! <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d2b3b0b1ffb3a2bb92e3fce2fce2">[email protected]</a> 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.
In an attempt to fix the issue, I tried reverting using npm run migration:revert
, but faced the same error. I then reverted the migration file back to its original state and created a new migration file specifically for renaming the column using
npm run migration:generate --filename
, yet still encountered the same error.
In one final effort to resolve the issue, I deleted the newly created migration file and ran only the original migration file (initial state), however, the error persisted.
I am seeking advice on how to rectify this situation as all I wanted to do was simply rename the column...
If more information or clarification is needed, please feel free to ask.
Your help and guidance are greatly appreciated.