Automate database migrations in deployment

This commit is contained in:
Hamza-Ayed
2026-04-17 01:31:09 +03:00
parent 1cfe3f6ca6
commit 32f53af974
2 changed files with 4 additions and 0 deletions

View File

@@ -20,6 +20,7 @@
"test:e2e": "jest --config ./test/jest-e2e.json",
"typeorm": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js",
"migration:run": "npm run typeorm -- migration:run -d src/data-source.ts",
"migration:run:prod": "node ./node_modules/typeorm/cli.js migration:run -d dist/data-source.js",
"migration:revert": "npm run typeorm -- migration:revert -d src/data-source.ts",
"migration:generate": "npm run typeorm -- migration:generate -d src/data-source.ts"
},

View File

@@ -62,6 +62,9 @@ ssh $SERVER_USER@$SERVER_IP << EOF
echo "🏗️ Rebuilding and starting production containers using \$DOCKER_CMD..."
\$DOCKER_CMD up -d --build
echo "🗄️ Running database migrations..."
\$DOCKER_CMD exec -T api npm run migration:run:prod
else
echo "❌ Error: docker-compose.yml not found!"
exit 1