Matched signals
- type "json" does not exist
- CHECK constraints cannot be marked NOT VALID
PostgreSQL migration failed due to unsupported type or constraint syntax
What this failure means
A database migration failed because the PostgreSQL version in CI does not support a type or constraint syntax used in the migration (e.g. the built-in JSON type requires PostgreSQL 9.2+, and NOT VALID constraints require 9.1+). Subsequent migration commands are skipped because the transaction is aborted.
Symptoms
Faultline looks for one or more of these log fragments:
type "json" does not exist
CHECK constraints cannot be marked NOT VALID
Diagnosis
The test suite runs migrations against a PostgreSQL instance that is older than the migration requires. The first failing statement aborts the transaction and causes all remaining migration commands to emit “current transaction is aborted” errors.
Common triggers:
type "json" does not exist— the migration uses the built-in JSON type, which was added in PostgreSQL 9.2. Any version below 9.2 will fail on this.CHECK constraints cannot be marked NOT VALID— the NOT VALID modifier for CHECK constraints was added in PostgreSQL 9.1.- The CI PostgreSQL service container is pinned to an old image tag (e.g.
postgres:9.0or unversionedpostgres:latestthat resolved to an old image when first written).
Fix steps
- Note the failing migration statement (e.g.
type "json" does not exist). - Check the PostgreSQL version running in CI:
psql --version # or in CI logs: look for "PostgreSQL X.Y" in the service startup output - Update the CI service to PostgreSQL 9.2 or later (13+ is recommended):
# GitHub Actions services: postgres: image: postgres:14 # Travis CI addons: postgresql: "14" - If the project must support older PostgreSQL, replace the JSON type with
TEXT and validate format in application code, or use the
hstoreextension for key-value data. - Re-run migrations after the version bump:
alembic upgrade head # or python manage.py migrate
Validation
- Confirm the PostgreSQL version in CI is 9.2 or later.
- Re-run the test suite. No
type "json" does not existorcurrent transaction is abortederrors should appear. make testpasses cleanly.
Why it matters
When a migration fails inside a transaction, the entire transaction is aborted. Every subsequent migration command fails with “current transaction is aborted, commands ignored until end of transaction block” — making the log appear to have many failures when the root cause is a single version-incompatibility at the top. Identifying the first real error is essential to resolving the failure quickly.
Prevention
- Pin the CI PostgreSQL image to an explicit major version (e.g.
postgres:14). - Document the minimum supported PostgreSQL version in the project README.
- Test migrations locally against the same version used in CI using Docker.
Try it locally
psql --version
docker run --rm postgres:9.0 psql -c 'SELECT 1::json'
python manage.py migrate --run-syncdb
alembic upgrade head
How Faultline detects it
Use faultline explain postgres-version-incompatible-migration to see the full playbook.
faultline analyze build.log
faultline explain postgres-version-incompatible-migration
Generated from playbooks/bundled/log/test/postgres-version-incompatible-migration.yaml. Do not edit directly.