Skip to main content

Module migrations

Module migrations 

Source

ModulesΒ§

conduit πŸ”’
moderation πŸ”’

StructsΒ§

PduRoomTs πŸ”’

ConstantsΒ§

DATABASE_VERSION πŸ”’
The current schema version.
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.
fix_bad_double_separator_in_state_cache πŸ”’
fix_hashed_sentinel_passwords πŸ”’
fix_readreceiptid_readreceipt_duplicates πŸ”’
fix_referencedevents_missing_sep πŸ”’
fresh πŸ”’
import_conduit_knocks πŸ”’
Imports a Conduit database’s pending knocks once. Gated on its own marker and the source column’s presence, so it runs only for a Conduit database and only the first time; a re-import would resurrect a knock the user later resolved.
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.
migrate πŸ”’
Apply any migrations
migrate_media πŸ”’
Imports a Conduit database’s content-addressed media into tuwunel’s key-addressed store when it is present and not yet imported; otherwise runs the key-addressed media migrations.
migrate_profile_keys πŸ”’
Relocates the per-user displayname and avatar_url out of their dedicated columns into the unified useridprofilekey_value store keyed by MSC4133 field name, where the profile service now reads them. The dedicated columns are left intact, so an older binary opening the same database still resolves.
migrations πŸ”’
rebuild_roomid_tscount_pducount πŸ”’
remove_remote_media_userid πŸ”’
retroactively_fix_bad_data_from_roomuserid_joined πŸ”’
split_conduit_highlight_counts πŸ”’
Splits a Conduit database’s conflated highlight-count column once. Conduit aliased roomuserid_lastnotificationread onto the userroomid_highlightcount tree, so one column holds both stores; tuwunel keeps them apart. Gated on its own marker; the split itself returns early unless a room-keyed row is present, so it is a cheap no-op on a native database.
upgrade_legacy_mediaid_user πŸ”’