Skip to main content

Module migrate

Module migrate 

Source
Expand description

Schema migrations — an ordered list of steps applied idempotently, tracked in a _orm_migrations table, against one executor or many.

For sharding this is the piece that creates each table on every shard: build a Migrator of the sharded entities and run_on_each it across the shard executors, and a second of the global entities against the global database. Migrations are wasm-safe (they only use Executor), so the same set runs from a server or inside a Worker.

ⓘ
use rainier_orm::migrate::Migrator;

let shard_schema = Migrator::new()
    .create_table::<User>("0001_users")
    .create_table::<Token>("0002_tokens")
    .add(MyCustomStep);          // impl Migration for anything bespoke

shard_schema.run_on_each(&shard_execs).await?;   // every shard
global_schema.run(&global_exec).await?;          // the directory DB

Structs§

CreateTable
A migration that creates E’s table (+ its indexes) from the derived schema, idempotently (CREATE TABLE IF NOT EXISTS).
Migrator
An ordered, idempotent set of migrations for one executor type X.

Traits§

Migration
One migration step. The unique name orders + dedupes it; up performs the change against an executor. Implement this on a struct for bespoke DDL, or use Migrator::create_table for the common “create this entity’s table”.

Type Aliases§

StepFuture
A future returned by a migration step — boxed so Migration stays object-safe (the runner holds Box<dyn Migration<X>>).