Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
web-et-numerique
web-et-numerique-internet
data.grandlyon.com
web-portal
components
services
organizations
Commits
10cfb4a9
Commit
10cfb4a9
authored
Feb 26, 2019
by
FORESTIER Fabien
Browse files
Variabilize path to migration file
parent
c6d65c71
Pipeline
#2397
passed with stages
in 2 minutes and 36 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
ormconfig.ts
View file @
10cfb4a9
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
.
export
s
=
ormConfig
;
package.json
View file @
10cfb4a9
...
...
@@ -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"
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment