<# .SYNOPSIS Test database setup (Windows / PowerShell wrapper). .DESCRIPTION Calls the PHP runner tests/setup_test_db.php, which in a single process: 1. reads connection params from .env (hostname/hostport/username/password/ charset/prefix/database) 2. derives the test DB name as {env.database} + '_test' (e.g. ulthon_admin -> ulthon_admin_test) 3. CREATE DATABASE IF NOT EXISTS on the same MySQL instance (no Docker) 4. config-level override connections.main -> test DB 5. php think migrate:run -> system/framework tables (database/migrations/) 6. php think scheme:sync -> business tables (app/admin/scheme/) 7. php think seed:run -> reference data (database/seeds/) 8. queries information_schema to verify the tables landed in the test DB Fully parameterized: no hardcoded host/port/credentials. The MySQL instance is whatever .env points at (typically a single local MySQL). .NOTES ASCII-only on purpose: PowerShell 5.1 mis-decodes BOM-less UTF-8 CJK. #> # Runner lives next to this script. $Runner = Join-Path $PSScriptRoot 'setup_test_db.php' # 1. Ensure php is on PATH. $phpCmd = Get-Command php -ErrorAction SilentlyContinue if (-not $phpCmd) { Write-Host "[ERROR] 'php' not found on PATH. Install PHP 8+ and add it to PATH." -ForegroundColor Red exit 1 } # 2. Run the PHP runner. Write-Host "==== Running setup_test_db.php ====" -ForegroundColor Cyan & php $Runner $code = $LASTEXITCODE Write-Host "" if ($code -eq 0) { Write-Host "==== Done. PHP exit code = $code ====" -ForegroundColor Green } else { Write-Host "==== Done. PHP exit code = $code ====" -ForegroundColor Red } exit $code