Skip to content

Commit

Permalink
Ensure flyway migrations are not changed (and validate them)
Browse files Browse the repository at this point in the history
  • Loading branch information
theosanderson committed Aug 2, 2024
1 parent 41b1a59 commit d45be3f
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/flyway-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Flyway Migration Check

on:
pull_request:
branches: [ main ]
paths:
- 'src/main/resources/db/migration/**'

jobs:
check-migrations:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'

- name: Install Flyway CLI
run: |
wget -qO- https://repo1.maven.org/maven2/org/flywaydb/flyway-commandline/8.5.13/flyway-commandline-8.5.13-linux-x64.tar.gz | tar xvz
sudo ln -s `pwd`/flyway-8.5.13/flyway /usr/local/bin
- name: Check for modified migrations
run: |
git diff --name-only origin/main...HEAD -- backend/src/main/resources/db/migration/ > changed_files.txt
if [ -s changed_files.txt ]; then
echo "The following migration files have been modified:"
cat changed_files.txt
echo "Error: Modifying existing migrations is not allowed."
exit 1
else
echo "No existing migrations have been modified."
fi
- name: Validate new migrations
run: flyway validate -locations=filesystem:backend/src/main/resources/db/migration

- name: Run Flyway info
run: flyway info -locations=filesystem:backend/src/main/resources/db/migration

0 comments on commit d45be3f

Please sign in to comment.