feat(conversation): add TypeORM migration scripts and data-source config

- Add migration:run, migration:revert, migration:generate scripts
- Create data-source.ts for TypeORM CLI
- Add dotenv, ts-node, tsconfig-paths dependencies

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-24 06:38:41 -08:00
parent cd5399eac3
commit c0a9710943
2 changed files with 27 additions and 1 deletions

View File

@ -11,7 +11,11 @@
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\"",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage"
"test:cov": "jest --coverage",
"typeorm": "typeorm-ts-node-commonjs",
"migration:run": "npm run typeorm migration:run -- -d src/data-source.ts",
"migration:revert": "npm run typeorm migration:revert -- -d src/data-source.ts",
"migration:generate": "npm run typeorm migration:generate -- -d src/data-source.ts"
},
"dependencies": {
"@anthropic-ai/sdk": "^0.52.0",
@ -41,8 +45,11 @@
"@types/node": "^20.10.0",
"@types/socket.io": "^3.0.2",
"@types/uuid": "^9.0.0",
"dotenv": "^16.3.0",
"jest": "^29.7.0",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.0",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.3.0"
}
}

View File

@ -0,0 +1,19 @@
import { DataSource } from 'typeorm';
import * as dotenv from 'dotenv';
// Load environment variables
dotenv.config({ path: '.env.local' });
dotenv.config({ path: '.env' });
export const AppDataSource = new DataSource({
type: 'postgres',
host: process.env.POSTGRES_HOST || 'localhost',
port: parseInt(process.env.POSTGRES_PORT || '5432', 10),
username: process.env.POSTGRES_USER || 'iconsulting',
password: process.env.POSTGRES_PASSWORD,
database: process.env.POSTGRES_DB || 'iconsulting',
entities: [__dirname + '/**/*.entity{.ts,.js}'],
migrations: [__dirname + '/migrations/*{.ts,.js}'],
synchronize: false,
logging: true,
});