forked from utmgdsc/hacklab-booking
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreset_db_state.dev.ps1
34 lines (29 loc) · 1.13 KB
/
reset_db_state.dev.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<#
.SYNOPSIS
Resets the dev env. Only run this when needed.
.DESCRIPTION
Resets the database state for the dev environment. This includes:
- removing all containers
- removing all volumes (including orphaned volumes)
- removing all images (including orphaned images)
- removing all logs
- removing all database data
After that, it starts the dev environment again and reconfigures postgres.
Precondition:
- Docker is running. The script will fail otherwise.
- The script's cwd in the repo's root directory.
- The docker backend starts within 30 seconds.
#>
# completely resets the database state
docker compose -f docker-compose.dev.yml down -v --rmi all --remove-orphans
Remove-Item "./backend/logs" -Recurse
Remove-Item "./db_data" -Recurse
Remove-Item "./backend/node_modules" -Recurse
Set-Location backend
npm ci
Set-Location ..
docker compose -f docker-compose.dev.yml up -d
timeout 30
# restart backend to make sure it connects to the database
docker compose -f docker-compose.dev.yml exec backend bash -c "cd app;npx prisma migrate dev"
docker compose -f docker-compose.dev.yml restart backend