小编Dio*_*ski的帖子

TypeORM CLI:未发现数据库架构发生变化

我正在使用 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)

migration typeorm nestjs

22
推荐指数
1
解决办法
7085
查看次数

标签 统计

migration ×1

nestjs ×1

typeorm ×1