File tree 2 files changed +20
-17
lines changed
2 files changed +20
-17
lines changed Original file line number Diff line number Diff line change 13
13
"mig:make" : " npm run knex migrate:make -- -x ts" ,
14
14
"seed" : " npm run knex seed:run" ,
15
15
"seed:make" : " npm run knex seed:make -- -x ts" ,
16
- "seed:single" : " ts-node --project ./apps/library/src/app/db-config/tsconfig.json ./node_modules/.bin/knex --knexfile ./apps/library/src/app/db-config/knexfile.ts seed:run -- --verbose --specific"
16
+ "seed:single" : " ts-node --project ./apps/library/src/app/db-config/tsconfig.json ./node_modules/.bin/knex --knexfile ./apps/library/src/app/db-config/knexfile.ts seed:run -- --verbose --specific" ,
17
+ "db:reset" : " node reset-db.js"
17
18
},
18
19
"private" : true ,
19
20
"dependencies" : {
Original file line number Diff line number Diff line change @@ -3,38 +3,40 @@ const Knex = require('knex')
3
3
// You can dynamically pass the database name
4
4
// as a command-line argument, or obtain it from
5
5
// a .env file
6
- const databaseName = 'lib1'
6
+ const databaseName = 'lib1' ;
7
7
8
8
const connection = {
9
9
host : 'localhost' ,
10
10
user : 'postgres' ,
11
- password : 'postgres'
12
- }
11
+ password : 'postgres' ,
12
+ port : 5432 ,
13
+ ssl : false ,
14
+ } ;
13
15
14
16
async function main ( ) {
15
17
let knex = Knex ( {
16
- client : 'mysql ' ,
18
+ client : 'pg ' ,
17
19
connection
18
- } )
20
+ } ) ;
19
21
22
+ await knex . raw ( 'DROP DATABASE IF EXISTS ?? ' , databaseName )
20
23
// Lets create our database if it does not exist
21
- await knex . raw ( 'CREATE DATABASE IF NOT EXISTS ??' , databaseName )
22
-
24
+ await knex . raw ( 'CREATE DATABASE ?? ' , databaseName )
23
25
24
26
// Now that our database is known, let's create another knex object
25
27
// with database name specified so that we can run our migrations
26
- knex = Knex ( {
27
- client : 'mysql ' ,
28
- connection : {
29
- ...connection ,
30
- database : databaseName ,
31
- }
32
- } )
28
+ // knex = Knex({
29
+ // client: 'pg ',
30
+ // connection: {
31
+ // ...connection,
32
+ // database: databaseName,
33
+ // }
34
+ // });
33
35
34
36
// Now we can happily run our migrations
35
- await knex . migrate . latest ( )
37
+ // await knex.migrate.latest();
36
38
37
39
// Done!!
38
40
}
39
41
40
- main ( ) . catch ( console . log ) . then ( process . exit )
42
+ main ( ) . catch ( console . log ) . then ( process . exit ) ;
You can’t perform that action at this time.
0 commit comments