11import { Knex } from 'knex' ;
22import dotenv from 'dotenv' ;
3+ import path from 'path' ;
4+
5+ let envFile : string ;
6+
7+ switch ( process . env [ 'NODE_ENV' ] ) {
8+ case 'production' :
9+ envFile = '../.env.production' ;
10+ break ;
11+ case 'development' :
12+ envFile = '../.env.development' ;
13+ break ;
14+ case 'test' :
15+ envFile = '../.env.test' ;
16+ break ;
17+ default :
18+ envFile = '../.env.local' ;
19+ }
320
4- const envFile =
5- process . env [ 'NODE_ENV' ] === 'production'
6- ? '../.env.production'
7- : process . env [ 'NODE_ENV' ] === 'test'
8- ? '../.env.test'
9- : '../.env.local' ;
1021dotenv . config ( { path : envFile } ) ;
1122
1223const config : { [ key : string ] : Knex . Config } = {
24+ local : {
25+ client : 'pg' ,
26+ connection : process . env [ 'DATABASE_URL' ] ,
27+ migrations : {
28+ directory : path . join ( __dirname , '../migrations' ) ,
29+ } ,
30+ seeds : {
31+ directory : path . join ( __dirname , '../seeds' ) ,
32+ } ,
33+ debug : true ,
34+ } ,
1335 development : {
1436 client : 'pg' ,
1537 connection : process . env [ 'DATABASE_URL' ] ,
@@ -24,10 +46,10 @@ const config: { [key: string]: Knex.Config } = {
2446 client : 'pg' ,
2547 connection : process . env [ 'DATABASE_URL' ] ,
2648 migrations : {
27- directory : '. /migrations',
49+ directory : path . join ( __dirname , '.. /migrations') ,
2850 } ,
2951 seeds : {
30- directory : '. /seeds',
52+ directory : path . join ( __dirname , '.. /seeds') ,
3153 } ,
3254 } ,
3355 production : {
0 commit comments