no changes in database schema were found - cannot generate a migration. to create a new empty migration use "typeorm migration:create" command code example

Example: no changes in database schema were found - cannot generate a migration. to create a new empty migration use "typeorm migration:create" command

These are the steps that i took to make it work:

Add an empty migration and on the up method add a query to drop all your tables.
Example:

await queryRunner.query(DROP TABLE "table_name");

Remove this migration

Remove your dist folder

Remove your .idea folder

Start your service - i used nest start (this should add a new and clean dist folder)

Check your ormconfig.json file for your "migrations" location.

Mine was:

"migrations": [ "dist/database/migration/*.js" ]

Check this path in the dist folder - i had no folder there with the name "migration".

Add the folder migration (or use the name you have in the ormconfig.json)

Run your migration:generate like before and it should work

(npm run typeorm -- migration:generate -n migration_name)

Hope it helped!

Tags:

Misc Example