Node.js TypeORM迁移未发现任何更改

Node.js TypeORM迁移未发现任何更改,node.js,migration,typeorm,Node.js,Migration,Typeorm,我正在尝试用TypeOrm生成迁移。当我更改一个实体时,它应该检测到这个更改并生成一个新的迁移 我收到以下错误消息: 未找到数据库架构中的任何更改-无法生成迁移。要创建新的空迁移,请使用“typeorm migration:create”命令 当我更改实体文件中的某些内容时,为什么会收到此错误消息 我正在使用此命令运行TypeForm: "typeorm": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js

我正在尝试用TypeOrm生成迁移。当我更改一个实体时,它应该检测到这个更改并生成一个新的迁移

我收到以下错误消息:

未找到数据库架构中的任何更改-无法生成迁移。要创建新的空迁移,请使用“typeorm migration:create”命令

当我更改实体文件中的某些内容时,为什么会收到此错误消息

我正在使用此命令运行TypeForm:

    "typeorm": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js --config src/typeormConfig.ts",
这是我的typeormConfig.ts文件:

import { ConnectionOptions } from "typeorm";
import * as path from "path";
import * as dotEnv from 'dotenv'

console.log(path.resolve(__dirname, 'entity/**.entity.ts'))

const result = dotEnv.config({ path: './ormconfig.env' });

if (result.error) {
  throw result.error
}

const config: ConnectionOptions = {
  type: 'mysql',
  host: process.env.TYPEORM_HOST,
  port: +process.env.TYPEORM_PORT,
  username: process.env.TYPEORM_USERNAME,
  password: process.env.TYPEORM_PASSWORD,
  database: process.env.TYPEORM_DATABASE,
  //synchronize: true,
  synchronize: false,
  // migrationsRun: false,
  entities: [path.resolve(__dirname, 'entity/**.entity.*')],
  migrations: [path.resolve(__dirname, 'migration/**')],
  cli: {
    entitiesDir: "src/entity",
    migrationsDir: "src/migration"
  }
}

export default config;

像这样更新entities&migrations目录链接

entities: [__dirname + '/entity/**/*.entity.ts', __dirname + '/entity/**/*.entity.js'],
migrations: [__dirname + '/migration/**/*.ts', __dirname + '/migration/**/*.js'],
它对我有用&应该有用

  • 确保已配置:
  • “迁移”:[“db migrations/*{.ts、.js}”],
    “cli”:{
    “migrationsDir”:“数据库迁移”
    }
    
  • 启用
    同步
    并转到上一页。模式的状态(运行项目-这将重置数据库更改)
  • 进行代码更改(从git应用代码或移动到更改的分支)
  • 禁用
    synchronize
    并运行项目(使其编译更改)-它可能无法运行,但正常
  • 运行
    typeormmigration:generate-n TestMigration
    ,它将成功

  • 从那里开始,在休假时
    同步
    已禁用,只需在运行
    迁移:生成

    之前编译项目,您是否尝试将
    导出默认配置
    替换为
    导出=配置