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 DBStructs§
- Create
Table - 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
nameorders + dedupes it;upperforms the change against an executor. Implement this on a struct for bespoke DDL, or useMigrator::create_tablefor the common “create this entity’s table”.
Type Aliases§
- Step
Future - A future returned by a migration step — boxed so
Migrationstays object-safe (the runner holdsBox<dyn Migration<X>>).