Assertions over Ecto schemas and migrations, built on
Presubmit.Adapters.EctoSchema and Presubmit.Adapters.EctoMigration.
Migrations are discovered by use Ecto.Migration rather than by path, so
a non-standard priv/*/migrations layout works unchanged.
Summary
Functions
Asserts every index the commit creates is created concurrently: true
inside a migration that disables the DDL transaction, so it does not lock
the table on PostgreSQL.
Asserts that migrations which existed before the commit are unchanged: not modified, deleted, or renamed.
Asserts every migration the commit adds has a version newer than every migration that already existed.
Asserts every migration the commit adds can be rolled back: it defines
down/0, or a change/0 whose execute calls all provide a down statement.
Asserts every column a schema gains in this commit is added to the schema's table by a migration in this commit.
Every migration in the resulting tree, oldest first.
Migrations the commit adds.
Functions
@spec assert_indexes_concurrent(Presubmit.Commit.t()) :: :ok
Asserts every index the commit creates is created concurrently: true
inside a migration that disables the DDL transaction, so it does not lock
the table on PostgreSQL.
@spec assert_migrations_immutable(Presubmit.Commit.t(), keyword()) :: :ok | {:skip, String.t()}
Asserts that migrations which existed before the commit are unchanged: not modified, deleted, or renamed.
With since: ref, only migrations present on ref (say "origin/main")
are immutable, so a migration that is still unmerged can be edited freely.
Returns {:skip, reason} when ref cannot be resolved.
@spec assert_migrations_ordered(Presubmit.Commit.t()) :: :ok
Asserts every migration the commit adds has a version newer than every migration that already existed.
A migration generated on a branch and rebased onto newer ones would sort before them and never run on a database that already applied the newer ones.
@spec assert_migrations_reversible(Presubmit.Commit.t()) :: :ok
Asserts every migration the commit adds can be rolled back: it defines
down/0, or a change/0 whose execute calls all provide a down statement.
@spec assert_schema_changes_migrated(Presubmit.Commit.t()) :: :ok
Asserts every column a schema gains in this commit is added to the schema's table by a migration in this commit.
Only field and belongs_to declarations map to columns; associations
and embeds are ignored. Schemas without a source (embedded) are skipped.
@spec migrations(Presubmit.Commit.t()) :: [Presubmit.Adapters.EctoMigration.t()]
Every migration in the resulting tree, oldest first.
@spec migrations_added(Presubmit.Commit.t()) :: [Presubmit.Adapters.EctoMigration.t()]
Migrations the commit adds.