Function apply
pub async fn apply<'e, E>(executor: E) -> Result<(), PostgresEventStoreError>where
E: PgExecutor<'e>,event-store and (crate features event-store or projection-store) only.Expand description
Applies MIGRATION_1 and then MIGRATION_3 to whatever schema
executor resolves against.
Which schema that is depends on the connection’s search_path, and this
function deliberately does not set it: a caller pointing a pool at one schema
and a caller using the default public are both legitimate, and a library
that silently rewrites search_path breaks the first one. The test fixture
creates a schema per instance and sets the path on the pool; a consumer does
whatever their deployment does.
§Upgrading a schema an older build migrated
Run this against it, then deploy. Both migrations are idempotent, so on
such a schema only MIGRATION_3 does anything. Its ALTER TABLEs take
a brief exclusive lock on event, and its index build blocks writes while
it runs; migrations/0003_write_group.sql says how to build the index
beforehand without blocking them.
§Errors
PostgresEventStoreError::Driver if the server rejects the statements —
most plausibly because the role cannot create objects in the target schema.