-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit-dummy-data-all.ps1
More file actions
65 lines (57 loc) · 3.4 KB
/
init-dummy-data-all.ps1
File metadata and controls
65 lines (57 loc) · 3.4 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# PowerShell script to initialize all dummy data
# Run this from the docker-compose directory
Write-Host "Copying SQL files to container..." -ForegroundColor Green
docker cp init-dummy-data-catalog.sql library-postgres:/tmp/init-dummy-data-catalog.sql
docker cp init-dummy-data-policy.sql library-postgres:/tmp/init-dummy-data-policy.sql
Write-Host "Waiting for services to create tables..." -ForegroundColor Yellow
Start-Sleep -Seconds 10
Write-Host "Inserting catalog data (resources)..." -ForegroundColor Green
docker exec -i library-postgres psql -U postgres -d catalog_db -f /tmp/init-dummy-data-catalog.sql
Write-Host "Inserting policy data..." -ForegroundColor Green
docker exec -i library-postgres psql -U postgres -d policy_db -f /tmp/init-dummy-data-policy.sql
Write-Host "Creating admin user via API (ensures correct password hash)..." -ForegroundColor Green
# Use the setup-admin-user script to create and approve admin user
& "$PSScriptRoot\setup-admin-user.ps1"
Write-Host "Creating dummy student and faculty users via API..." -ForegroundColor Green
# Use the setup-dummy-users script to create student and faculty users
& "$PSScriptRoot\setup-dummy-users.ps1"
Write-Host "Verifying data..." -ForegroundColor Green
Write-Host "Resources count:" -ForegroundColor Cyan
docker exec library-postgres psql -U postgres -d catalog_db -c "SELECT COUNT(*) FROM resources;"
Write-Host "Policies count:" -ForegroundColor Cyan
docker exec library-postgres psql -U postgres -d policy_db -c "SELECT COUNT(*) FROM booking_policies;"
Write-Host "Users:" -ForegroundColor Cyan
docker exec library-postgres psql -U postgres -d user_db -c "SELECT username, email, role, pending_approval FROM users WHERE username IN ('admin1', 'admin2', 'student1', 'student2', 'faculty1', 'faculty2') ORDER BY role, username;"
Write-Host ""
Write-Host "User Credentials:" -ForegroundColor Green
Write-Host "Admins:" -ForegroundColor Cyan
Write-Host " Admin 1:" -ForegroundColor Yellow
Write-Host " Username: admin1" -ForegroundColor Gray
Write-Host " Password: 12345678a" -ForegroundColor Gray
Write-Host " Email: admin@gmail.com" -ForegroundColor Gray
Write-Host " Admin 2:" -ForegroundColor Yellow
Write-Host " Username: admin2" -ForegroundColor Gray
Write-Host " Password: 12345678a" -ForegroundColor Gray
Write-Host " Email: admin2@gmail.com" -ForegroundColor Gray
Write-Host ""
Write-Host "Students:" -ForegroundColor Cyan
Write-Host " Student 1:" -ForegroundColor Yellow
Write-Host " Username: student1" -ForegroundColor Gray
Write-Host " Password: 12345678s" -ForegroundColor Gray
Write-Host " Email: student1@example.com" -ForegroundColor Gray
Write-Host " Student 2:" -ForegroundColor Yellow
Write-Host " Username: student2" -ForegroundColor Gray
Write-Host " Password: 12345678s" -ForegroundColor Gray
Write-Host " Email: student2@example.com" -ForegroundColor Gray
Write-Host ""
Write-Host "Faculty:" -ForegroundColor Cyan
Write-Host " Faculty 1:" -ForegroundColor Yellow
Write-Host " Username: faculty1" -ForegroundColor Gray
Write-Host " Password: 12345678f" -ForegroundColor Gray
Write-Host " Email: faculty1@example.com" -ForegroundColor Gray
Write-Host " Faculty 2:" -ForegroundColor Yellow
Write-Host " Username: faculty2" -ForegroundColor Gray
Write-Host " Password: 12345678f" -ForegroundColor Gray
Write-Host " Email: faculty2@example.com" -ForegroundColor Gray
Write-Host ""
Write-Host "Done!" -ForegroundColor Green