diff --git a/Docker/scripts/deploy_database.sh b/Docker/scripts/deploy_database.sh index 4ee735ee..fde46d12 100755 --- a/Docker/scripts/deploy_database.sh +++ b/Docker/scripts/deploy_database.sh @@ -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