75 lines
3.0 KiB
PowerShell
75 lines
3.0 KiB
PowerShell
# Script para aplicar migration de confirmation_status
|
|
# Data: 2025-12-03
|
|
|
|
Write-Host "==================================" -ForegroundColor Cyan
|
|
Write-Host "Aplicando Migration: confirmation_status" -ForegroundColor Cyan
|
|
Write-Host "==================================" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
|
|
$migrationFile = "supabase\migrations\20251203000000_add_confirmation_status.sql"
|
|
|
|
if (-not (Test-Path $migrationFile)) {
|
|
Write-Host "❌ Arquivo de migration não encontrado: $migrationFile" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
|
|
Write-Host "📄 Lendo arquivo de migration..." -ForegroundColor Yellow
|
|
$sqlContent = Get-Content $migrationFile -Raw
|
|
|
|
Write-Host "✅ Migration carregada com sucesso!" -ForegroundColor Green
|
|
Write-Host ""
|
|
Write-Host "📋 Conteúdo da migration:" -ForegroundColor Cyan
|
|
Write-Host "----------------------------------------" -ForegroundColor Gray
|
|
Write-Host $sqlContent -ForegroundColor White
|
|
Write-Host "----------------------------------------" -ForegroundColor Gray
|
|
Write-Host ""
|
|
|
|
Write-Host "⚠️ ATENÇÃO: Certifique-se de que:" -ForegroundColor Yellow
|
|
Write-Host " 1. O Supabase local está rodando (supabase start)" -ForegroundColor White
|
|
Write-Host " 2. Você tem as credenciais de acesso configuradas" -ForegroundColor White
|
|
Write-Host ""
|
|
|
|
$confirm = Read-Host "Deseja aplicar esta migration? (S/N)"
|
|
|
|
if ($confirm -ne "S" -and $confirm -ne "s") {
|
|
Write-Host "❌ Operação cancelada pelo usuário." -ForegroundColor Red
|
|
exit 0
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "🚀 Aplicando migration..." -ForegroundColor Cyan
|
|
|
|
try {
|
|
# Aplicar via Supabase CLI
|
|
$output = supabase db push 2>&1
|
|
|
|
if ($LASTEXITCODE -eq 0) {
|
|
Write-Host "✅ Migration aplicada com sucesso!" -ForegroundColor Green
|
|
Write-Host ""
|
|
Write-Host "📊 Verificando resultado..." -ForegroundColor Cyan
|
|
|
|
# Verificar se a coluna foi criada
|
|
$checkSql = "SELECT column_name, data_type FROM information_schema.columns WHERE table_name = 'appointments' AND column_name IN ('confirmation_status', 'confirmed_at');"
|
|
|
|
Write-Host ""
|
|
Write-Host "Execute este comando para verificar:" -ForegroundColor Yellow
|
|
Write-Host "supabase db query '$checkSql'" -ForegroundColor White
|
|
} else {
|
|
Write-Host "❌ Erro ao aplicar migration!" -ForegroundColor Red
|
|
Write-Host $output -ForegroundColor Red
|
|
}
|
|
} catch {
|
|
Write-Host "❌ Erro ao executar comando: $_" -ForegroundColor Red
|
|
Write-Host ""
|
|
Write-Host "💡 Tente aplicar manualmente:" -ForegroundColor Yellow
|
|
Write-Host " 1. Abra o Supabase Dashboard" -ForegroundColor White
|
|
Write-Host " 2. Vá para SQL Editor" -ForegroundColor White
|
|
Write-Host " 3. Cole o conteúdo da migration" -ForegroundColor White
|
|
Write-Host " 4. Execute o SQL" -ForegroundColor White
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "==================================" -ForegroundColor Cyan
|
|
Write-Host "Processo concluído!" -ForegroundColor Cyan
|
|
Write-Host "==================================" -ForegroundColor Cyan
|