Skip to main content

Module database

Module database 

Source
Expand description

Module database utilities

Each module has its own database at {data_dir}/db/. Use this helper to open it. Modules use the same format as the node by default (via MODULE_CONFIG_DATABASE_BACKEND).

Structs§

MigrationContext
Context passed to migration functions. Provides put/get/delete against the module’s schema tree and access to the database for opening other trees.

Functions§

open_module_db
Open the module’s database at {data_dir}/db/.
run_migrations
Run pending up migrations. Opens the “schema” tree, reads current version, runs each migration with version > current in order, then updates schema_version.
run_migrations_down
Rollback migrations down to target_version (exclusive). Runs down migrations in reverse order for each applied version > target_version. Requires down functions to be provided.
run_migrations_with_down
Run pending up migrations. Supports optional down migrations for rollback.

Type Aliases§

Migration
Migration pair: (version, up, optional down for rollback).
MigrationDown
A single down migration step (for rollback).
MigrationUp
A single up migration step.