Initial commit 050212
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import { join } from 'path';
|
||||
import { DataSourceOptions } from 'typeorm';
|
||||
|
||||
/**
|
||||
* Runtime config for Nest TypeOrmModule.
|
||||
* After build, __dirname is dist/config; compiled entities live under dist.
|
||||
*/
|
||||
export const dataSourceOptions: DataSourceOptions = {
|
||||
type: 'postgres',
|
||||
host: process.env.DB_HOST,
|
||||
port: parseInt(process.env.POSTGRES_PORT || '5432', 10),
|
||||
username: process.env.POSTGRES_USER,
|
||||
password: process.env.POSTGRES_PASSWORD,
|
||||
database: process.env.POSTGRES_DB,
|
||||
entities: [join(__dirname, '..', '**', '*.entity.{ts,js}')],
|
||||
migrations: [join(__dirname, '..', 'database', 'migrations', '*.{ts,js}')],
|
||||
synchronize: process.env.DB_SYNC === 'true',
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
import 'dotenv/config';
|
||||
import { join } from 'path';
|
||||
import { DataSource } from 'typeorm';
|
||||
|
||||
/**
|
||||
* CLI-only DataSource (migration generate/run/revert).
|
||||
* Paths point at src so migrations stay in TypeScript before build.
|
||||
*/
|
||||
export default new DataSource({
|
||||
type: 'postgres',
|
||||
host: process.env.DB_HOST,
|
||||
port: parseInt(process.env.POSTGRES_PORT || '5432', 10),
|
||||
username: process.env.POSTGRES_USER,
|
||||
password: process.env.POSTGRES_PASSWORD,
|
||||
database: process.env.POSTGRES_DB,
|
||||
entities: [join(__dirname, '..', '**', '*.entity.ts')],
|
||||
migrations: [join(__dirname, 'migrations', '*.ts')],
|
||||
synchronize: false,
|
||||
});
|
||||
Reference in New Issue
Block a user