Squash migrations (#12830)

* Squash migrations for "users" app

* Squash migrations for "common" app

Note: we will come back again later to squash some more

* Significant squashing

* Update legacy migrations

* Further squashing of migrations

* Even more cleanup

* Adjust CI workflow

* Update CI Job

* Update docs

* Update CHANGELOG.md

* Cleanup old comments

* Throw error if pre 1.0.0 DB detected

* Refactor incomplete migration check
This commit is contained in:
Oliver
2026-09-11 16:03:41 +10:00
committed by GitHub
parent 028d1cba1f
commit c26db6a790
548 changed files with 5875 additions and 18451 deletions
+38 -30
View File
@@ -50,7 +50,7 @@ jobs:
contains(github.event.pull_request.labels.*.name, 'full-run')
sqlite:
name: Tests - Migrations [SQLite]
name: Migrations [SQLite]
runs-on: ubuntu-latest
needs: paths-filter
if: ${{ (needs.paths-filter.outputs.force == 'true') || (github.ref == 'refs/heads/master' && needs.paths-filter.outputs.migrations == 'true') }}
@@ -83,7 +83,7 @@ jobs:
flags: migrations-sqlite
mysql:
name: Tests - Migrations [MySQL]
name: Migrations [MySQL]
runs-on: ubuntu-24.04
needs: paths-filter
if: ${{ (needs.paths-filter.outputs.force == 'true') || (github.ref == 'refs/heads/master' && needs.paths-filter.outputs.migrations == 'true') }}
@@ -134,7 +134,7 @@ jobs:
flags: migrations-mysql
postgresql:
name: Tests - Migrations [PostgreSQL]
name: Migrations [PostgreSQL]
runs-on: ubuntu-latest
needs: paths-filter
if: ${{ (needs.paths-filter.outputs.force == 'true') || (github.ref == 'refs/heads/master' && needs.paths-filter.outputs.migrations == 'true') }}
@@ -181,7 +181,7 @@ jobs:
flags: migrations-postgresql
migrations-checks:
name: Tests - Database Migrations
name: Database Migrations
runs-on: ubuntu-latest
needs: paths-filter
if: ${{ (needs.paths-filter.outputs.force == 'true') || (github.ref == 'refs/heads/master' && needs.paths-filter.outputs.migrations == 'true') }}
@@ -205,37 +205,45 @@ jobs:
- name: Fetch Database
run: git clone --depth 1 https://github.com/inventree/test-db ./test-db
- name: 0.10.0 Database
- name: 1.0.0 Database
run: |
rm /home/runner/work/InvenTree/db.sqlite3
cp test-db/stable_1.0.0.sqlite3 /home/runner/work/InvenTree/db.sqlite3
chmod +rw /home/runner/work/InvenTree/db.sqlite3
invoke migrate
- name: 1.5.0 Database
run: |
rm /home/runner/work/InvenTree/db.sqlite3
cp test-db/stable_1.5.0.sqlite3 /home/runner/work/InvenTree/db.sqlite3
chmod +rw /home/runner/work/InvenTree/db.sqlite3
invoke migrate
- name: 0.10.0 Database (SHOULD FAIL)
run: |
rm /home/runner/work/InvenTree/db.sqlite3
cp test-db/stable_0.10.0.sqlite3 /home/runner/work/InvenTree/db.sqlite3
chmod +rw /home/runner/work/InvenTree/db.sqlite3
invoke migrate
- name: 0.11.0 Database
run: |
rm /home/runner/work/InvenTree/db.sqlite3
cp test-db/stable_0.11.0.sqlite3 /home/runner/work/InvenTree/db.sqlite3
chmod +rw /home/runner/work/InvenTree/db.sqlite3
invoke migrate
set +e
output=$(invoke migrate 2>&1)
exit_code=$?
set -e
- name: 0.13.5 Database
run: |
rm /home/runner/work/InvenTree/db.sqlite3
cp test-db/stable_0.13.5.sqlite3 /home/runner/work/InvenTree/db.sqlite3
chmod +rw /home/runner/work/InvenTree/db.sqlite3
invoke migrate
# Always show the actual output, so the reason for pass/fail is visible
# in the job log rather than just a generic summary line
echo "$output"
- name: 0.16.0 Database
run: |
rm /home/runner/work/InvenTree/db.sqlite3
cp test-db/stable_0.16.0.sqlite3 /home/runner/work/InvenTree/db.sqlite3
chmod +rw /home/runner/work/InvenTree/db.sqlite3
invoke migrate
if [ "$exit_code" -eq 0 ]; then
echo "::error::Migration succeeded for 0.10.0 database, but this is expected to fail (squashed migrations no longer support this old baseline)"
exit 1
fi
- name: 0.17.0 Database
run: |
rm /home/runner/work/InvenTree/db.sqlite3
cp test-db/stable_0.17.0.sqlite3 /home/runner/work/InvenTree/db.sqlite3
chmod +rw /home/runner/work/InvenTree/db.sqlite3
invoke migrate
# Confirm it failed for the *expected* reason (INVE-E19: stuck mid-way
# through the pre-1.0.0 migration squash), not some unrelated crash
if echo "$output" | grep -q "INVE-E19"; then
echo "Migration failed as expected for 0.10.0 database (INVE-E19)"
else
echo "::error::Migration failed for 0.10.0 database, but not with the expected INVE-E19 error - this looks like an unrelated failure"
exit 1
fi