Files
trade/data/db/data-source-cli.ts
T
Rekey d8a2f4bb52 refactor: 统一 TypeORM CLI 数据源配置,执行废弃列清理迁移
- data/db/data-source-cli.cjs → .ts,复用 config 模块的 pgsql 配置
- 新增迁移 CleanupTradingPairDeprecatedColumns,删除 trading_pairs 表三个废弃列
- reasonix.toml: model 升级 deepseek-pro,启用中文
2026-06-16 12:29:23 +08:00

40 lines
1.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* TypeORM CLI 专用数据源配置
*
* 直接复用 config 模块的 pgsql 配置(含校验),
* 专供 TypeORM CLINode.js / tsx)使用。
*
* 使用方式:
* npx tsx node_modules/.bin/typeorm migration:run -d db/data-source-cli.ts
* npx tsx node_modules/.bin/typeorm migration:revert -d db/data-source-cli.ts
* npx tsx node_modules/.bin/typeorm migration:show -d db/data-source-cli.ts
*/
import { DataSource } from "typeorm";
import { fileURLToPath } from "node:url";
import { dirname } from "node:path";
import { pgsql } from "../config";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const AppDataSource = new DataSource({
type: "postgres",
host: pgsql.host,
port: pgsql.port,
database: pgsql.database,
username: pgsql.user,
password: pgsql.password,
entities: [__dirname + "/entities/*.{ts,js}"],
synchronize: false,
migrations: [__dirname + "/migrations/*.{ts,js}"],
extra: {
max: pgsql.max,
idleTimeoutMillis: pgsql.idleTimeoutMillis,
connectionTimeoutMillis: pgsql.connectionTimeoutMillis,
},
logging: ["error", "warn"],
});
export default AppDataSource;