当尝试运行 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/