• 简体中文
  • Flyway 迁移

    Firmiana 使用 Flyway 进行版本化 Schema 管理。共有 23 个迁移(V1–V23)。

    迁移历史

    版本名称阶段说明
    V1baseline_schemaP0核心表:users、rooms、events、tokens、devices
    V2three_pid_validationP0第三方 ID 验证表
    V3typing_streamP0输入指示器流
    V4receipt_streamP0已读回执流
    V5device_inboxP0设备间消息收件箱
    V6presence_streamP0用户在线状态流
    V7device_list_streamP0设备列表变更通知
    V8user_profileP0用户资料数据
    V9media_metadataP0媒体上传元数据
    V10user_pusherP0推送通知网关配置
    V11event_dag_minimalP0事件 DAG 关系
    V12forward_extremityP0前向极端跟踪
    V13state_group_and_auth_chainP0状态解析组
    V14p1_e2ee_pushP1端到端加密和推送通知表
    V15media_quarantineP1媒体隔离状态
    V16notification_tableP1通知投递跟踪
    V17media_thumbnailsP1缩略图缓存存储
    V18media_url_preview_cacheP1URL 预览缓存
    V19server_signing_keyP2联邦签名密钥存储
    V20appservice_registrationP2应用服务注册
    V21p3_index_additionsP3性能复合索引
    V22event_search_fulltextP3事件搜索内容索引
    V23space_and_relationsP4空间支持、事件关系

    迁移命名

    迁移遵循 Flyway 约定:V{version}__{description}.sql

    双下划线(__)分隔版本号和描述。

    添加新迁移

    src/main/resources/db/migration/ 中创建新的 SQL 文件:

    V24__description.sql

    文件应仅包含 DDL 语句(CREATE TABLE、ALTER TABLE、CREATE INDEX)。

    Warning

    永远不要修改现有的迁移文件。如果需要更改 Schema,请创建新的迁移。

    基线迁移

    基线 Schema(V1)创建核心表:

    • usersuser_passwordsuser_access_tokensuser_refresh_tokens
    • roomsroom_userroom_aliases
    • eventevent_relations
    • forward_extremityroom_state_group
    • device_inboxdevice_list_stream
    • typing_userpresence_streamreceiptroom_receipt
    • media_metadatamedia_auth_token
    • user_push_rulesuser_pushers
    • notificationevent_push_summary

    重置数据库

    重置数据库:

    rm -rf data/matrix*
    mvn exec:java

    Flyway 将从头重新运行所有迁移。