postgresql - NestJS、PortsgreSQL 和 TypeORM - 迁移运行不正常

标签 postgresql nestjs typeorm

当尝试运行 TypeORM 迁移时,无论是在应用程序启动时自动运行还是通过 TypeORM CLI 手动运行,都只会创建迁移表(并且它保持为空)。迁移文件本身没有被执行。

这是我的 tsconfig.json

{
  "compilerOptions": {
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "target": "es2017",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "incremental": true
  }
}

这是我的 package.json

...
"typeorm": "node --require ts-node/register ./node_modules/typeorm/cli.js",
...

这是我的 ormconfig.json

...
"entities": ["dist/**/*.entity{.ts,.js}"],
"synchronize": true,
"migrationsRun": true,
"migrations ": ["dist/migrations/*{.ts,.js}"],
"cli": {
    "migrationsDir": "src/migrations"
  }
...

迁移文件是通过 TypeORM CLI 创建的,它们将填充一些表(插入语句)。它们与数据库模式的更改无关。

拜托,任何人都可以帮我让它工作吗?

最佳答案

那是一个愚蠢的人! 我想有时候最简单的问题是最难发现的。

问题出在 ormconfig.json 文件中。 我删除了这个空白区域 ("migrations ":),一切正常。

关于postgresql - NestJS、PortsgreSQL 和 TypeORM - 迁移运行不正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63584034/

相关文章:

postgresql - 我可以将数组参数传递到 CTE 中吗?

linux - PostgreSQL psql 未启动

postgresql - 使用 Springboot 和 Postgres 废弃的连接池

typescript - Nest.js + TypeORM + OpenApi 中虚拟(计算)列的最佳实践

node.js - MongoDB、Mongoose 和 Apollo GraphQL 在文档中定义 _id 类型

database - 如何从Typeorm中的连接实体中仅选择单个/多个字段

postgresql - 使用 Between 查询 api Repository Typeorm 上的日期

sql - 调整查询以更新每个用户的总和

javascript - 如何在 graphql 中定义不带任何参数的突变或查询?

postgresql - TypeORM 查询生成器在原始 SQL 工作时返回空数组