Elixir "(Ecto.MigrationError)" in CI
Ecto raised a migration error: migrations are pending, two share a version, or a migration uses an operation the adapter rejects. The schema could not be brought to the expected state.
What this error means
A migration or test run fails with (Ecto.MigrationError) - pending migrations, duplicate version numbers, or cannot execute ... inside transaction. It is deterministic given the migrations.
** (Ecto.MigrationError) migrations can't be executed, migration
version 20260101120000 is duplicated
(ecto_sql 3.11.0) lib/ecto/migrator.ex: ...Common causes
Duplicate migration versions
Two migration files share the same timestamp prefix, so Ecto cannot order them and refuses to run.
Pending migrations in test
The test DB is behind the migrations; a check like Ecto.Migrator finds pending versions and raises.
Operation needs to run outside a transaction
An operation like CREATE INDEX CONCURRENTLY cannot run inside the default migration transaction.
How to fix it
Migrate the test DB before running tests
Bring the schema up to date so no migrations are pending.
MIX_ENV=test mix ecto.create
MIX_ENV=test mix ecto.migrateResolve version and transaction issues
- Give each migration a unique timestamp version.
- Use
@disable_ddl_transaction truefor concurrent operations. - Run
mix ecto.migrationsto inspect applied vs pending.
How to prevent it
- Generate migrations so versions stay unique.
- Migrate the test DB in the CI setup step.
- Flag operations that must run outside a transaction.