Search code examples
postgresqldatabase-migrationtypeormnestdrop

TypeORM migration:generate working great except for DROP


I have a NestJS / TypeORM Project with PostGRE SQL.

I want to delete some tables, so I have deleted the concerned folders. I also removed the dist folder to build the project again but even with that, typeORM does not detect that it have to DROP these tables on migration:generate.

All others cases of migrations are working well..

Is there any way to force TypeORM to detect Entity deletion ? I can't find solution for this.. I could do it manually, but I can't believe that typeORM can't do this simple process.


Solution

  • It's a known issue at the moment. Here is the link in the source repo: https://github.com/typeorm/typeorm/issues/7814.

    The workaround is to manually add the "DROP TABLE" statement to the generated migration file.
    You may copy it from the down method of the migration that created it.