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