Commit 10cfb4a9 authored by FORESTIER Fabien's avatar FORESTIER Fabien
Browse files

Variabilize path to migration file

parent c6d65c71
Pipeline #2397 passed with stages
in 2 minutes and 36 seconds
import * as dotenv from 'dotenv';
import * as fs from 'fs';
// tslint:disable-next-line:no-var-requires
const dotenv = require('dotenv');
// tslint:disable-next-line:no-var-requires
const fs = require('fs');
let root = 'src';
if (process.env.PRODBUILD) {
root = 'dist';
}
// Only for development purpose, set environment variable based on the env file provided
if (process.env.NODE_ENV === 'LOCAL') {
......@@ -18,26 +26,26 @@ const ormConfig = {
username: process.env.POSTGRES_USER,
password: process.env.POSTGRES_PASSWORD,
database: process.env.POSTGRES_DB,
entities: ['src/**/**.entity{.ts,.js}'],
entities: [`${root}/**/**.entity{.ts,.js}`],
synchronize: false,
migrations: ['src/migrations/*.ts'],
cli: { migrationsDir: 'src/migrations' },
migrations: [`${root}/migrations/*.ts`],
cli: { migrationsDir: `${root}/migrations` },
logging: true,
};
if (process.env.MIGRATION) {
if (process.env.NODE_ENV === 'LOCAL') {
ormConfig.username = process.env[`POSTGRES_USER`];
ormConfig.password = process.env[`POSTGRES_PASSWORD`];
ormConfig.database = process.env[`POSTGRES_DB`];
} else {
ormConfig.username = process.env[`${process.env.NODE_ENV}_POSTGRES_USER`];
ormConfig.password = process.env[`${process.env.NODE_ENV}_POSTGRES_PASSWORD`];
ormConfig.database = process.env[`${process.env.NODE_ENV}_POSTGRES_DB`];
}
ormConfig.host = process.env.POSTGRES_HOST_MIGRATION;
ormConfig.port = process.env[`${process.env.NODE_ENV}_POSTGRES_PORT`];
// if (process.env.MIGRATION) {
// if (process.env.NODE_ENV === 'LOCAL') {
// ormConfig.username = process.env[`POSTGRES_USER`];
// ormConfig.password = process.env[`POSTGRES_PASSWORD`];
// ormConfig.database = process.env[`POSTGRES_DB`];
// } else {
// ormConfig.username = process.env[`${process.env.NODE_ENV}_POSTGRES_USER`];
// ormConfig.password = process.env[`${process.env.NODE_ENV}_POSTGRES_PASSWORD`];
// ormConfig.database = process.env[`${process.env.NODE_ENV}_POSTGRES_DB`];
// }
// ormConfig.host = process.env.POSTGRES_HOST_MIGRATION;
// ormConfig.port = process.env[`${process.env.NODE_ENV}_POSTGRES_PORT`];
}
// }
export = ormConfig;
module.exports = ormConfig;
......@@ -10,7 +10,7 @@
"start:dev": "nodemon",
"start:debug": "nodemon --config nodemon-debug.json",
"prestart:prod": "rimraf dist && tsc",
"start:prod": "node dist/main.js",
"start:prod": "cross-env PRODBUILD=1 node dist/main.js",
"start:hmr": "node dist/server",
"lint": "tslint -p tsconfig.json -c tslint.json",
"test": "jest",
......
Supports Markdown
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