File tree Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change 99 "start-dev-server" : " tsc-watch --onSuccess \" node dist/server.js\" " ,
1010 "dev" : " npm-run-all clean build start-dev-server" ,
1111 "populate-db" : " npm-run-all clean build run-populate-db-script" ,
12- "run-populate-db-script" : " node dist/models/populate-db.js"
12+ "run-populate-db-script" : " node dist/models/populate-db.js" ,
13+ "delete-db" : " npm-run-all clean build run-delete-db-script" ,
14+ "run-delete-db-script" : " node dist/models/delete-db.js"
1315 },
1416 "author" : " " ,
1517 "license" : " MIT" ,
Original file line number Diff line number Diff line change 1+ import * as dotenv from "dotenv" ;
2+
3+ const result = dotenv . config ( ) ;
4+
5+ import "reflect-metadata" ;
6+ import { AppDataSource } from "../data-source" ;
7+ import { Lesson } from "./lesson" ;
8+ import { Course } from "./course" ;
9+
10+ async function deleteDb ( ) {
11+
12+ await AppDataSource . initialize ( ) ;
13+
14+ console . log ( `Database connection ready.` ) ;
15+
16+ console . log ( `Clearing LESSONS table.` ) ;
17+
18+ await AppDataSource . getRepository ( Lesson ) . delete ( { } ) ;
19+
20+ console . log ( `Clearing COURSES table.` ) ;
21+
22+ await AppDataSource . getRepository ( Course ) . delete ( { } ) ;
23+
24+ }
25+
26+
27+ deleteDb ( )
28+ . then ( ( ) => {
29+ console . log ( `Finished deleting database, exiting!` ) ;
30+ process . exit ( 0 ) ;
31+ } )
32+ . catch ( err => {
33+ console . error ( `Error deleting database.` , err ) ;
34+ } ) ;
You can’t perform that action at this time.
0 commit comments