postgresql - TypeORM CLI - 如何在特定数据库上运行迁移
问题描述
我ormconfig.json
有多个数据库,如何为此列表的特定数据库运行迁移?在下面的示例中,我dev
已经设置了迁移的数据库,现在我需要为另一个名为test
.
我想运行这样的命令:
yarn typeorm migration:run --database test
// ormconfig.json
[
{
"name": "dev",
"type": "postgres",
"host": "localhost",
"port": 5432,
"username": "postgres",
"password": "postgres",
"database": "postgres",
"synchronize": true,
"logging": true,
"entities": ["src/typeorm/entity/**/*.ts"],
"migrations": ["src/typeorm/migration/**/*.ts"],
"subscribers": ["src/typeorm/subscriber/**/*.ts"],
"cli": {
"entitiesDir": "src/typeorm/entity",
"migrationsDir": "src/typeorm/migration",
"subscribersDir": "src/typeorm/subscriber"
}
},
{
"name": "test",
"type": "postgres",
"host": "localhost",
"port": 5433,
"username": "postgres",
"password": "postgres",
"database": "postgres",
"synchronize": true,
"logging": false,
"entities": ["src/typeorm/entity/**/*.ts"],
"migrations": ["src/typeorm/migration/**/*.ts"],
"subscribers": ["src/typeorm/subscriber/**/*.ts"],
"cli": {
"entitiesDir": "src/typeorm/entity",
"migrationsDir": "src/typeorm/migration",
"subscribersDir": "src/typeorm/subscriber"
}
}
]
解决方案
赶紧跑:
yarn typeorm migration:run -c configName
其中 configName 是name
您的ormconfig.json
数据库列表中的配置。
推荐阅读
- python - Analog `as_completed` in the `multiprocessing` module
- java - Error when trying to use Simple-JNDI
- linux-kernel - What restriction is perf_event_paranoid == 1 actually putting on x86 perf?
- node.js - 是否可以在节点 Microsoft bot 中使用 MSAL 进行 B2C 身份验证登录?
- javascript - 我怎样才能保留所有这些 html 文件?
- async-await - Yeoman,在 composeWith 之前使用 yosay
- arrays - 如果对象存在,如何_update_数组内的Mongo对象,如果不存在,将其添加到数组中?
- amazon-web-services - CloudFormation 无权执行:iam:PassRole on resource
- python - Conversion types in Python
- function - What is the difference between a cmdlet and a function?