-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce Flyway to manage db schema (#15)
- Loading branch information
1 parent
b4ac7ae
commit d21219f
Showing
6 changed files
with
62 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: DB Migration | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
paths: | ||
- db/** | ||
pull_request: | ||
branches: [ main ] | ||
paths: | ||
- db/** | ||
workflow_dispatch: | ||
|
||
jobs: | ||
db-schema-migration: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: 'Test flyway migration scripts' | ||
working-directory: ./db | ||
run: | | ||
./run_migrations_test.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
SET client_encoding = 'UTF8'; | ||
|
||
CREATE TABLE aircraft_offer ( | ||
id SERIAL PRIMARY KEY, | ||
date DATE, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
echo "Starting Postgres docker container" | ||
|
||
docker network create test-network | ||
|
||
docker run --rm \ | ||
--name test-db \ | ||
-d \ | ||
--network test-network \ | ||
-e 'POSTGRES_DB=aircraft_offers' \ | ||
-e 'POSTGRES_USER=aircraft_offers' \ | ||
-e 'POSTGRES_PASSWORD=aircraft_offers' \ | ||
postgres:15-alpine | ||
|
||
sleep 2 | ||
|
||
echo "Running migrations" | ||
|
||
docker run --rm \ | ||
--network test-network \ | ||
-v ${PWD}'/migrations/:/flyway/sql' \ | ||
flyway/flyway \ | ||
-url=jdbc:postgresql://test-db:5432/aircraft_offers -user=aircraft_offers -password=aircraft_offers migrate | ||
|
||
docker rm -f test-db | ||
docker network rm test-network |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters