File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515 DATABASE_URL : postgres://postgres:password@localhost:5432/test_db?sslmode=disable
1616 DBMATE_MIGRATIONS_DIR : ./migrations
1717 DBMATE_SCHEMA_FILE : ./database.sql
18-
18+
1919 services :
2020 postgres :
2121 image : postgres:15
4545 run : |
4646 # Apply migrations, dumps schema
4747 dbmate up
48-
48+
4949 # Check if the schema file has changed
5050 if git diff --exit-code database.sql; then
5151 echo "✅ Schema validation passed - database.sql is in sync with migrations"
6262 echo " git add database.sql && git commit -m 'Update schema'"
6363 exit 1
6464 fi
65+
66+ - name : Test that down migrations work
67+ run : |
68+ # Drop db from previous test
69+ dbmate drop
70+ # Apply migrations
71+ dbmate up
72+
73+ for i in ./migrations/*
74+ do
75+ if test -f "$i"
76+ then
77+ # The command will fail if something is wrong
78+ dbmate down
79+ fi
80+ done;
81+
82+ # Check if migrations can be run again
83+ dbmate up
You can’t perform that action at this time.
0 commit comments