infracloud/dev-scripts/create_db.ps1
2026-03-04 05:58:41 -06:00

27 lines
1 KiB
PowerShell

$token = Get-Content 'c:\Users\Administrator\.ssh\coolify-redbull-token'
$baseUrl = "https://redbull.rede5.com.br/api/v1"
$body = @{
server_uuid = "m844o4gkwkwcc0k48swgs8c8"
project_uuid = "t0c4ss0wkcgwg48g088wkwgs"
environment_name = "production"
name = "postgres-db"
description = "Shared PostgreSQL Database"
postgres_user = "coolify"
postgres_password = "Shared#User#Password#123!4"
postgres_db = "postgres_db"
image = "postgres:16"
} | ConvertTo-Json
Write-Host "Creating Database..."
try {
$response = Invoke-RestMethod -Uri "$baseUrl/databases/postgresql" -Headers @{Authorization = "Bearer $token" } -Method Post -Body $body -ContentType "application/json"
$response | ConvertTo-Json -Depth 5 | Out-File -Encoding ASCII c:\dev\create_db.json
Write-Host "Success!"
}
catch {
Write-Host "Error: $($_.Exception.Message)"
if ($_.ErrorDetails) {
Write-Host "Details: $($_.ErrorDetails.Message)"
}
}