THE ORIONIS API
Build with clarity.
Explore the building blocks of an async-first Python framework. Every module, class, and method — connected, searchable, and ready to build with.
Runner applying and reverting the application migrations.
Migrations are discovered under database/migrations and applied in filename order, which is chronological because filenames carry a zero-padded sequential prefix. Each migration runs inside its own transaction together with its tracking record, so a failure never leaves the tracking table claiming a migration that did not fully apply.
| Static Method | __next |
Compute the batch number to assign to a new migration run. |
| Static Method | __select |
Pick the recorded rows belonging to the batches being reverted. |
| Method | __connection |
Resolve the connection migrations run against. |
| Async Method | __delete |
Remove a migration's tracking record. |
| Method | __discover |
Discover migration classes defined under the migrations directory. |
| Async Method | __ensure |
Create the migrations tracking table if it does not already exist. |
| Async Method | __get |
Return every recorded migration, ordered by application order. |
| Method | __init__ |
Initialize the migrator. |
| Async Method | __insert |
Record a migration as applied. |
| Method | __migrations |
Return the directory holding migration files. |
| Async Method | __revert |
Roll back the recorded migrations of the selected batches. |
| Async Method | __run |
Run one migration and its tracking write atomically. |
| Async Method | fresh |
Drop migration and seeder history, then apply every migration. |
| Async Method | migrate |
Apply every migration that has not been run yet. |
| Async Method | refresh |
Roll back migrations and immediately apply them again. |
| Async Method | reset |
Revert every migration recorded on the connection. |
| Async Method | rollback |
Revert the most recently applied migration batches. |
| Async Method | status |
Report which migrations are applied and which are pending. |
| Class Variable | __slots__ |
Undocumented |
| Instance Variable | __app |
Undocumented |
| Instance Variable | __conn |
Undocumented |
| Instance Variable | __discovered |
Undocumented |
Resolve the connection migrations run against.
| Parameters | |
name:str or None | Named connection, or None for the default one. |
| Returns | |
IConnection | Connection bound to its configuration. |
| Raises | |
ConnectionNotFoundException | If the connection is not declared in the configuration. |
Remove a migration's tracking record.
| Parameters | |
connection:IConnection | Connection used to run the statement. |
name:str | Migration name to remove. |
| Returns | |
None | This method does not return a value. |
Discover migration classes defined under the migrations directory.
The result is cached on the instance after the first call, since the migrations directory does not change during a process lifetime and discovery involves filesystem traversal, module imports, and reflection. Only classes defined in a migration module are eligible; package initializers and reexports are ignored.
| Returns | |
dict of str to type | Migration classes keyed by module file stem, ordered chronologically (filenames are zero-padded sequential ids). |
| Raises | |
ValueError | If multiple classes share a persisted migration name. |
Create the migrations tracking table if it does not already exist.
| Parameters | |
connection:IConnection | Connection used to perform the schema operation. |
| Returns | |
None | This method does not return a value. |
Return every recorded migration, ordered by application order.
| Parameters | |
connection:IConnection | Connection used to run the query. |
| Returns | |
list of dict | Rows with id, migration, and batch keys. |
Initialize the migrator.
| Parameters | |
app:IApplication | Application instance used to resolve the migrations directory. |
connIConnectionManager | Connection manager used to resolve the database connection. |
| Returns | |
None | This method does not return a value. |
Record a migration as applied.
| Parameters | |
connection:IConnection | Connection used to run the statement. |
name:str | Migration name to record. |
batch:int | Batch number the migration belongs to. |
| Returns | |
None | This method does not return a value. |
Return the directory holding migration files.
| Returns | |
Path | Absolute path to the database_migrations directory under the application base path. |
int | None, connection: str | None, events: MigrationEvents | None) -> list[ str]:
(source)
¶
Roll back the recorded migrations of the selected batches.
| Parameters | |
steps:int or None | Number of most recent batches to revert; None reverts every recorded migration. |
connection:str or None | Named connection to roll back, or None for the default. |
events:MigrationEvents or None | Progress callbacks reported for each migration. |
| Returns | |
list of str | Names of the migrations reverted, most recent first. |
| Raises | |
MigrationNotFoundException | If a recorded migration has no matching migration file. |
IConnection, name: str, migration_cls: type[ Migration], batch: int | None, events: MigrationEvents, *, clear_seeders: bool = False):
(source)
¶
Run one migration and its tracking write atomically.
| Parameters | |
connection:IConnection | Connection the migration runs against. |
name:str | Migration name. |
migrationtype of Migration | Migration class to instantiate and run. |
batch:int or None | Batch number to record when applying; None reverts the migration instead. |
events:MigrationEvents | Progress callbacks reported for this migration. |
clearbool, optional | Drop seeder history when this is the last applied migration. |
| Returns | |
None | This method does not return a value. |
| Raises | |
Exception | Any exception raised by the migration propagates after the transaction is rolled back and the failure is reported. |
str | None = None, events: MigrationEvents | None = None) -> list[ str]:
(source)
¶
Drop migration and seeder history, then apply every migration.
Unlike refresh, the tracking table itself is dropped, so
the whole history is rebuilt as a single first batch. Seeder history
is also removed when an older rollback left it behind.
| Parameters | |
connection:str or None, optional | Named connection to rebuild, or None for the default. |
events:MigrationEvents or None, optional | Progress callbacks reported for each migration. |
| Returns | |
list of str | Names of the migrations applied, in the order they ran. |
str | None = None, events: MigrationEvents | None = None) -> list[ str]:
(source)
¶
Apply every migration that has not been run yet.
| Parameters | |
connection:str or None, optional | Named connection to migrate, or None for the default one. |
events:MigrationEvents or None, optional | Progress callbacks reported for each migration. |
| Returns | |
list of str | Names of the migrations applied, in the order they ran. |
| Raises | |
Exception | Any exception raised by a migration up method aborts the run and propagates to the caller. |
int | None = None, *, connection: str | None = None, events: MigrationEvents | None = None) -> list[ str]:
(source)
¶
Roll back migrations and immediately apply them again.
| Parameters | |
steps:int or None, optional | Number of batches to roll back first; None rolls back every recorded migration. |
connection:str or None, optional | Named connection to refresh, or None for the default. |
events:MigrationEvents or None, optional | Progress callbacks reported for each migration. |
| Returns | |
list of str | Names of the migrations re-applied, in the order they ran. |
| Raises | |
ValueError | If steps is not a positive integer. |
str | None = None, events: MigrationEvents | None = None) -> list[ str]:
(source)
¶
Revert every migration recorded on the connection.
| Parameters | |
connection:str or None, optional | Named connection to reset, or None for the default one. |
events:MigrationEvents or None, optional | Progress callbacks reported for each migration. |
| Returns | |
list of str | Names of the migrations reverted, most recent first. |
| Raises | |
MigrationNotFoundException | If a recorded migration has no matching migration file. |
int = 1, *, connection: str | None = None, events: MigrationEvents | None = None) -> list[ str]:
(source)
¶
Revert the most recently applied migration batches.
| Parameters | |
steps:int, optional | Number of batches to roll back, starting from the most recent one. Defaults to 1. |
connection:str or None, optional | Named connection to roll back, or None for the default. |
events:MigrationEvents or None, optional | Progress callbacks reported for each migration. |
| Returns | |
list of str | Names of the migrations reverted, most recent first. |
| Raises | |
ValueError | If steps is not a positive integer. |
MigrationNotFoundException | If a recorded migration has no matching migration file. |