mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-13 15:14:49 -06:00
fix: rollback deploy_database.sh
This commit is contained in:
parent
0c5d28bb6c
commit
95401cf9b0
@ -1,36 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Fonte das variáveis de ambiente
|
||||
source ./Docker/scripts/env_functions.sh
|
||||
|
||||
# Carregar variáveis de ambiente se não estiver no ambiente Docker
|
||||
if [ "$DOCKER_ENV" != "true" ]; then
|
||||
export_env_vars
|
||||
fi
|
||||
|
||||
# Verificar se o banco de dados é PostgreSQL ou MySQL
|
||||
if [[ "$DATABASE_PROVIDER" == "postgresql" || "$DATABASE_PROVIDER" == "mysql" ]]; then
|
||||
export DATABASE_URL
|
||||
echo "Deploying migrations for $DATABASE_PROVIDER"
|
||||
echo "Database URL: $DATABASE_URL"
|
||||
|
||||
# Verificar se há migrações pendentes com Prisma
|
||||
MIGRATION_STATUS=$(npx prisma migrate status)
|
||||
|
||||
if echo "$MIGRATION_STATUS" | grep -q "Pending"; then
|
||||
echo "Migrações pendentes encontradas. Executando deploy..."
|
||||
npm run db:deploy # Aplica as migrações pendentes
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Migration failed"
|
||||
exit 1
|
||||
else
|
||||
echo "Migration succeeded"
|
||||
fi
|
||||
# rm -rf ./prisma/migrations
|
||||
# cp -r ./prisma/$DATABASE_PROVIDER-migrations ./prisma/migrations
|
||||
npm run db:deploy
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Migration failed"
|
||||
exit 1
|
||||
else
|
||||
echo "Nenhuma migração pendente. Pulando deploy."
|
||||
echo "Migration succeeded"
|
||||
fi
|
||||
|
||||
# Gerar o Prisma Client após o deploy
|
||||
npm run db:generate
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Prisma generate failed"
|
||||
@ -38,7 +26,6 @@ if [[ "$DATABASE_PROVIDER" == "postgresql" || "$DATABASE_PROVIDER" == "mysql" ]]
|
||||
else
|
||||
echo "Prisma generate succeeded"
|
||||
fi
|
||||
|
||||
else
|
||||
echo "Error: Database provider $DATABASE_PROVIDER invalid."
|
||||
exit 1
|
||||
|
Loading…
Reference in New Issue
Block a user