File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -43,15 +43,29 @@ jobs:
4343 pg_isready -h localhost -p 5432 && break || sleep 5
4444 done
4545
46- - name : Run migrations
46+ - name : Sync Database
4747 env :
48+ NODE_ENV : test
4849 DB_USERNAME : postgres
4950 DB_PASSWORD : 12345678
5051 DB_NAME : database_services_test
5152 DB_HOST : localhost
5253 JWT_SECRET : supersecretkey
5354 JWT_EXPIRES_IN : 1h
54- run : yarn migrate
55+ run : yarn sync-db
56+
57+ - name : Wait for database to settle
58+ run : sleep 5
59+
60+ # - name: Run migrations
61+ # env:
62+ # DB_USERNAME: postgres
63+ # DB_PASSWORD: 12345678
64+ # DB_NAME: database_services_test
65+ # DB_HOST: localhost
66+ # JWT_SECRET: supersecretkey
67+ # JWT_EXPIRES_IN: 1h
68+ # run: yarn migrate
5569
5670 - name : Run tests
5771 env :
Original file line number Diff line number Diff line change 1111 "seed" : " sequelize-cli db:seed:all" ,
1212 "prepare" : " husky install" ,
1313 "lint" : " eslint src" ,
14- "test" : " jest"
14+ "test" : " jest" ,
15+ "sync-db" : " ts-node ./src/sync.ts"
1516 },
1617 "dependencies" : {
1718 "@tsconfig/node16" : " ^16.1.3" ,
Original file line number Diff line number Diff line change 1+ import { sequelize } from './config/database' ;
2+
3+ async function syncDatabase ( ) {
4+ try {
5+ await sequelize . sync ( { force : true } ) ;
6+ console . log ( 'Database synchronized successfully.' ) ;
7+ process . exit ( 0 ) ;
8+ } catch ( error ) {
9+ console . error ( 'Failed to synchronize database:' , error ) ;
10+ process . exit ( 1 ) ;
11+ }
12+ }
13+
14+ syncDatabase ( ) ;
You can’t perform that action at this time.
0 commit comments