-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-databases.ps1
More file actions
38 lines (29 loc) · 1.6 KB
/
Copy pathsetup-databases.ps1
File metadata and controls
38 lines (29 loc) · 1.6 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
# PostgreSQL Database Setup Script
# Run this script as Administrator
$PSQL_PATH = "C:\Program Files\PostgreSQL\17\bin\psql.exe"
$PG_USER = "postgres"
Write-Host "[INFO] Setting up Remote Process Monitor databases..." -ForegroundColor Cyan
# Check if psql is available
if (-not (Test-Path $PSQL_PATH)) {
Write-Host "[ERROR] PostgreSQL psql not found at: $PSQL_PATH" -ForegroundColor Red
Write-Host "Please update the PSQL_PATH variable in this script" -ForegroundColor Yellow
exit 1
}
# Create databases
Write-Host "`n[INFO] Creating databases..." -ForegroundColor Cyan
# Create live database
Write-Host "Creating proc_monitor_live database..." -ForegroundColor Yellow
& $PSQL_PATH -U $PG_USER -c "DROP DATABASE IF EXISTS proc_monitor_live;"
& $PSQL_PATH -U $PG_USER -c "CREATE DATABASE proc_monitor_live;"
# Create logs database
Write-Host "Creating proc_monitor_logs database..." -ForegroundColor Yellow
& $PSQL_PATH -U $PG_USER -c "DROP DATABASE IF EXISTS proc_monitor_logs;"
& $PSQL_PATH -U $PG_USER -c "CREATE DATABASE proc_monitor_logs;"
# Run migrations for live database
Write-Host "`n[INFO] Running migrations for live database..." -ForegroundColor Cyan
& $PSQL_PATH -U $PG_USER -d proc_monitor_live -f "database\migrations\001_create_live_db.sql"
# Run migrations for logs database
Write-Host "`n[INFO] Running migrations for logs database..." -ForegroundColor Cyan
& $PSQL_PATH -U $PG_USER -d proc_monitor_logs -f "database\migrations\002_create_log_db.sql"
Write-Host "`n[OK] Database setup complete!" -ForegroundColor Green
Write-Host "`nYou can now start the server with: npm start" -ForegroundColor Cyan