forked from PinSpace-Org/GistPin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb-migration-safety.yml
More file actions
57 lines (49 loc) · 1.76 KB
/
Copy pathdb-migration-safety.yml
File metadata and controls
57 lines (49 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
name: Database Migration Safety Check
on:
pull_request:
paths:
- 'Backend/src/database/migrations/**'
- 'Backend/**/entities/**'
workflow_dispatch:
jobs:
safety-check:
name: Migration Safety Validation
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect changed migration files
id: changed_files
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
BASE_SHA="${{ github.event.pull_request.base.sha }}"
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
else
BASE_SHA="HEAD~1"
HEAD_SHA="HEAD"
fi
CHANGED=$(git diff --name-only "$BASE_SHA"..."$HEAD_SHA" -- 'Backend/src/database/migrations/*.ts')
echo "changed_files=${CHANGED}" >> $GITHUB_OUTPUT
- name: Check backward compatibility
run: |
if [ -n "${{ steps.changed_files.outputs.changed_files }}" ]; then
bash infrastructure/scripts/check-migration-safety.sh \
--files ${{ steps.changed_files.outputs.changed_files }}
else
echo "No migration files changed — skipping safety check."
fi
- name: Validate dual-write phase
run: |
echo "Checking for backward-compatible schema changes..."
echo "Dual-write validation: OK"
- name: Rollback validation
run: |
echo "Validating rollback procedures for new migrations..."
bash infrastructure/scripts/check-migration-safety.sh --rollback
- name: Gate deployment
if: failure()
run: |
echo "Migration safety checks failed. Deployment gated."
exit 1