Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
615 views
in Technique[技术] by (71.8m points)

typeorm migration:generate can't detect removed files from entities directory

In Typeorm, migration: generate works fine when I create a new entity file or when I add a new column to the existing entity. But when I delete any entity file from the entities folder, it cannot detect it. For my case this is src/models/*.ts

question from:https://stackoverflow.com/questions/65911354/typeorm-migrationgenerate-cant-detect-removed-files-from-entities-directory

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I think this is a wanted behaviour. What you want is a match between entity and table, when the entity is deleted TypeORM should generate a migration file where the table will be deleted. But there are often tables which have no entity representation, but should not be removed. In your case you need to manually create an empty migration file typeorm migration:create -c default -n DropTable and drop the table.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.8k users

...