|
- <#
- .SYNOPSIS
- First-time setup of the Foundry Knowledge Engine: .env, containers, schema migrations.
- .DESCRIPTION
- 1. Creates .env with a random POSTGRES_PASSWORD if it does not exist (never overwritten).
- 2. Starts PostgreSQL (docker compose up -d) and waits until it is healthy.
- 3. Applies pending migrations from infrastructure/postgres/migrations (idempotent).
- 4. Reports the health of the knowledge system, including the embedding model.
- #>
- [CmdletBinding()]
- param()
- $ErrorActionPreference = 'Stop'
- $root = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
- $envFile = Join-Path $root '.env'
- if (-not (Test-Path -LiteralPath $envFile)) {
- $bytes = [byte[]]::new(24)
- [Security.Cryptography.RandomNumberGenerator]::Fill($bytes)
- $pw = [Convert]::ToHexString($bytes).ToLowerInvariant()
- [IO.File]::WriteAllText($envFile, "POSTGRES_PASSWORD=$pw`n", [Text.UTF8Encoding]::new($false))
- Write-Host 'Created .env with a generated password (not committed).'
- }
- & (Join-Path $PSScriptRoot 'Start-Foundry.ps1')
- Import-Module (Join-Path $root 'powershell/Foundry.Knowledge/Foundry.Knowledge.psd1') -Force
- Update-FoundryDatabase
- Test-FoundryKnowledge | Format-List
|