Skip to content
Snippets Groups Projects
Commit b2a76fc6 authored by stevereis's avatar stevereis
Browse files

fix(typeorm): Config issue after Typeorm update

parent b521f461
No related branches found
No related tags found
No related merge requests found
import { ConfigModule } from '@nestjs/config';
import { DataSource } from 'typeorm';
import dbConfiguration from './src/config/db.config';
ConfigModule.forRoot({
......@@ -12,9 +13,10 @@ const ormconfig = {
entities: ['dist/**/*.entity.js', 'dist/**/*.model.js'],
migrations: ['dist/migrations/*{.ts,.js}'],
migrationsRun: false,
cli: {
migrationsDir: 'src/migrations',
},
};
export default ormconfig;
const connSource = new DataSource(ormconfig);
connSource.initialize();
export default connSource;
......@@ -22,8 +22,8 @@
"test:we2e": "jest --watch --config ./test/jest.e2e-config.ts",
"prepare": "cd .. && husky install api/.husky",
"typeorm": "node --require ts-node/register ./node_modules/typeorm/cli.js",
"typeorm:migration:generate": "npm run typeorm -- migration:generate -n",
"typeorm:migration:run": "npm run typeorm -- migration:run"
"typeorm:migration:generate": "npm run typeorm -- migration:generate -d ormconfig.ts",
"typeorm:migration:run": "npm run typeorm -- migration:run -d ormconfig.ts"
},
"dependencies": {
"@nestjs/apollo": "^10.0.22",
......
import { registerAs } from '@nestjs/config';
import { PostgresConnectionOptions } from 'typeorm/driver/postgres/PostgresConnectionOptions';
export default registerAs('database', () => {
export default registerAs('database', (): PostgresConnectionOptions => {
return {
type: 'postgres',
host: process.env.DB_HOST || 'localhost',
......@@ -8,5 +9,6 @@ export default registerAs('database', () => {
username: process.env.DB_USERNAME || 'postgres',
password: process.env.DB_PASSWORD || 'pass123',
database: process.env.DB_NAME || 'postgres',
synchronize: process.env.NODE_ENV === 'development',
};
});
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment