Skip to content

Commit 95401cf

Browse files
authored
fix: rollback deploy_database.sh
1 parent 0c5d28b commit 95401cf

File tree

1 file changed

+7
-20
lines changed

1 file changed

+7
-20
lines changed

Docker/scripts/deploy_database.sh

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,31 @@
11
#!/bin/bash
22

3-
# Fonte das variáveis de ambiente
43
source ./Docker/scripts/env_functions.sh
54

6-
# Carregar variáveis de ambiente se não estiver no ambiente Docker
75
if [ "$DOCKER_ENV" != "true" ]; then
86
export_env_vars
97
fi
108

11-
# Verificar se o banco de dados é PostgreSQL ou MySQL
129
if [[ "$DATABASE_PROVIDER" == "postgresql" || "$DATABASE_PROVIDER" == "mysql" ]]; then
1310
export DATABASE_URL
1411
echo "Deploying migrations for $DATABASE_PROVIDER"
1512
echo "Database URL: $DATABASE_URL"
16-
17-
# Verificar se há migrações pendentes com Prisma
18-
MIGRATION_STATUS=$(npx prisma migrate status)
19-
20-
if echo "$MIGRATION_STATUS" | grep -q "Pending"; then
21-
echo "Migrações pendentes encontradas. Executando deploy..."
22-
npm run db:deploy # Aplica as migrações pendentes
23-
if [ $? -ne 0 ]; then
24-
echo "Migration failed"
25-
exit 1
26-
else
27-
echo "Migration succeeded"
28-
fi
13+
# rm -rf ./prisma/migrations
14+
# cp -r ./prisma/$DATABASE_PROVIDER-migrations ./prisma/migrations
15+
npm run db:deploy
16+
if [ $? -ne 0 ]; then
17+
echo "Migration failed"
18+
exit 1
2919
else
30-
echo "Nenhuma migração pendente. Pulando deploy."
20+
echo "Migration succeeded"
3121
fi
32-
33-
# Gerar o Prisma Client após o deploy
3422
npm run db:generate
3523
if [ $? -ne 0 ]; then
3624
echo "Prisma generate failed"
3725
exit 1
3826
else
3927
echo "Prisma generate succeeded"
4028
fi
41-
4229
else
4330
echo "Error: Database provider $DATABASE_PROVIDER invalid."
4431
exit 1

0 commit comments

Comments
 (0)