Automate database migrations in deployment
This commit is contained in:
@@ -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"
|
||||
},
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user