【发布时间】:2020-12-14 10:49:41
【问题描述】:
当尝试运行 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 创建,它们将填充一些表(插入语句)。它们与数据库架构的更改无关。
拜托,谁能帮我完成它?
【问题讨论】:
-
运行这个命令
npx typeorm migration:run -
我试过了,但唯一发生的是迁移表已创建(如果尚未创建)。就好像我用插入语句创建的迁移文件没有找到一样。我检查了
"migrations": ["dist/migrations/*{.ts,.js}"],文件(.ts 和 .js)都在那里。
标签: postgresql nestjs typeorm