我正在使用 NestJS 和 TypeORM 开发应用程序。每当我尝试从我的实体生成迁移(通过运行typeorm migration:generate)时,我都会收到以下消息:
No changes in database schema were found - cannot generate a migration. To create a new empty migration use "typeorm migration:create" command
Run Code Online (Sandbox Code Playgroud)
我什至删除了所有现有的迁移文件(从迁移文件夹中)以排除任何冲突的可能性。
在我将应用程序的模块文件夹结构更改为:
src
|- config
| |- database
| |- mysql
| |- cli-configuration.ts
|- migrations
|- module1
|- controller
|- entity
|- service
Run Code Online (Sandbox Code Playgroud)
可以看出,migrations文件夹就在下面src,每个模块都有一个entity文件夹,其中放置了该模块的实体。所有 ormconfig 设置都来自cli-configuration.ts文件。
在package.json文件中,我添加了以下内容scripts:
{
...
"scripts": {
...
"typeorm": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js …Run Code Online (Sandbox Code Playgroud)