Skip to content

Commit 622edcf

Browse files
Turtlatorclaude
andcommitted
Add database migration step to deployment workflow
Run prisma migrate deploy after infrastructure deployment to apply pending migrations before the app starts. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 6cf83e7 commit 622edcf

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ jobs:
7373
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
7474

7575
- name: Deploy Infrastructure
76+
id: deploy
7677
run: |
7778
az deployment group create \
7879
--name "happy-server-${{ github.sha }}" \
@@ -88,6 +89,27 @@ jobs:
8889
imageTag="${{ github.sha }}" \
8990
acrName="${{ env.ACR_NAME }}"
9091
92+
# Get postgres FQDN from deployment output
93+
POSTGRES_FQDN=$(az deployment group show \
94+
--name "happy-server-${{ github.sha }}" \
95+
--resource-group "${{ env.RESOURCE_GROUP }}" \
96+
--query "properties.outputs.postgresServerFqdn.value" -o tsv)
97+
echo "postgres-fqdn=$POSTGRES_FQDN" >> $GITHUB_OUTPUT
98+
99+
- name: Setup Node.js
100+
uses: actions/setup-node@v4
101+
with:
102+
node-version: '20'
103+
cache: 'yarn'
104+
105+
- name: Install Dependencies
106+
run: yarn install --frozen-lockfile
107+
108+
- name: Run Database Migrations
109+
run: npx prisma migrate deploy
110+
env:
111+
DATABASE_URL: postgresql://happyadmin:${{ secrets.POSTGRES_PASSWORD }}@${{ steps.deploy.outputs.postgres-fqdn }}:5432/happy?sslmode=require
112+
91113
- name: Get App URL
92114
id: get-url
93115
run: |

0 commit comments

Comments
 (0)