Initial commit: 浼佷笟寰俊 AI 鏈哄櫒浜哄姪鐞?MVP
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
31
deploy/scripts/migrate.ps1
Normal file
31
deploy/scripts/migrate.ps1
Normal file
@@ -0,0 +1,31 @@
|
||||
# One-click migrate (Docker). Run from project root: .\deploy\scripts\migrate.ps1
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$ProjectRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
|
||||
Set-Location $ProjectRoot
|
||||
|
||||
Write-Host "[1/3] Starting database..." -ForegroundColor Cyan
|
||||
docker compose up -d db
|
||||
|
||||
Write-Host "[2/3] Waiting for DB ready..." -ForegroundColor Cyan
|
||||
$max = 30
|
||||
for ($i = 0; $i -lt $max; $i++) {
|
||||
$null = docker compose exec -T db pg_isready -U wecom -d wecom_ai 2>$null
|
||||
if ($LASTEXITCODE -eq 0) { break }
|
||||
Start-Sleep -Seconds 1
|
||||
}
|
||||
if ($i -ge $max) {
|
||||
Write-Host "DB not ready in ${max}s. Check: docker compose logs db" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "[3/3] Running Alembic upgrade head..." -ForegroundColor Cyan
|
||||
docker compose run --rm backend sh -c "alembic upgrade head"
|
||||
$code = $LASTEXITCODE
|
||||
|
||||
if ($code -eq 0) {
|
||||
Write-Host "Migrate done." -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Migrate failed. See errors above." -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
Reference in New Issue
Block a user