Skip to main content

Module migrations

Module migrations 

Source
Expand description

One-time database migrations.

A fresh database is stamped current and a legacy database is walked through the named migrations, once the version and server name gates decide it is safe to touch.

ModulesΒ§

account_status πŸ”’
clear_servername_status πŸ”’
conduit πŸ”’
email_bindings πŸ”’
fix_bad_double_separator_in_state_cache πŸ”’
fix_hashed_sentinel_passwords πŸ”’
fix_readreceiptid_readreceipt_duplicates πŸ”’
fix_referencedevents_missing_sep πŸ”’
import_conduit_knocks πŸ”’
injectivity πŸ”’
Short id injectivity: the one-time scan and repair.
migrate_media πŸ”’
migrate_profile_keys πŸ”’
moderation πŸ”’
rebuild_roomid_tscount_pducount πŸ”’
remove_remote_media_userid πŸ”’
retroactively_fix_bad_data_from_roomuserid_joined πŸ”’
split_conduit_highlight_counts πŸ”’
upgrade_legacy_mediaid_user πŸ”’

ConstantsΒ§

DATABASE_VERSION πŸ”’
The current schema version.
FORCE_MIGRATION_DELAY πŸ”’
FOREIGN_LINEAGE_MARKER πŸ”’
A marker written by a sibling conduwuit-lineage server but never by tuwunel. Its presence identifies a foreign database at a higher schema number even after tuwunel has stamped its own server_name, so a database opened by both servers in turn keeps booting rather than being refused as too new.
SERVER_NAME_KEY πŸ”’

FunctionsΒ§

backfill_server_name πŸ”’
Stamp the marker on a database that pre-dates SERVER_NAME_KEY by probing for any user from the configured server. If none, the database belongs to a different server and reuse is refused.
check_database_version πŸ”’
Gate the discovered schema version before migrations and the server_name backfill run. The integer is comparable only within tuwunel’s own lineage; a foreign database (Conduit and forks) numbers schema on a colliding ladder and is recognized as foreign by is_foreign_lineage, so its number is not gated. Within our lineage a version below 13 is refused as unmigratable and one above this build as too new to open safely; force_migration overrides the latter for a deliberate downgrade.
check_server_name πŸ”’
Matrix resource ownership is based on the server name; changing it requires recreating the database from scratch. The marker is stamped once in fresh(); pre-marker databases are backfilled by probing for any user from the configured server.
fresh πŸ”’
is_foreign_lineage πŸ”’
Whether the database comes from a foreign (non-tuwunel) lineage: it predates our SERVER_NAME_KEY stamp, or carries a conduwuit-lineage migration marker that persists even after we stamp ours. Must be read before the server_name backfill, which removes the first signal.
local_user_id πŸ”’
Assembles a local user id from a localpart a foreign column records.
migrate πŸ”’
Apply any migrations
migrations πŸ”’

Type AliasesΒ§

UserIdBuf πŸ”’
Inline budget for a local user id assembled from a foreign localpart.