npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

koishi-plugin-chatluna-datamigration

v1.0.3

Published

Clean and migrate dirty ChatLuna 1.3 room data into ChatLuna 1.4 conversation tables.

Readme

koishi-plugin-chatluna-datamigration

用于把 ChatLuna 1.3 的 chathub_* 老房间数据清洗后迁移到 ChatLuna 1.4 的 chatluna_* 会话表。

推荐方案:净化原表

ChatLuna 1.4 安装/启用时会自动检查 chathub_* 旧表并执行内置迁移。 因此最稳的路线不是绕过它,而是在启用 1.4 前先把 1.3 原表净化好:

  1. 备份 chathub_*chatluna_dm_chathub_*
  2. 从备份表读取原始数据。
  3. 清洗脏房间、悬挂 latestId、坏时间、无效成员、重复消息 id 等。
  4. 覆盖回原 chathub_* 表。
  5. 再启用 ChatLuna 1.4,让它用干净旧表执行官方内置迁移。

shield + migrate 是备用方案:它会把旧表移开并由本插件直接写入 1.4 新表。 一般优先使用 purify

推荐流程

  1. 停止 Koishi。
  2. 安装并启用本插件 koishi-plugin-chatluna-datamigration
  3. 禁用 koishi-plugin-chatluna 1.4,只启用数据库插件和本插件。
  4. 启动 Koishi。
  5. 执行 chatluna-datamigration.status 查看旧表数量。
  6. 执行 chatluna-datamigration.purify 预演。
  7. 确认后执行 chatluna-datamigration.purify --apply
  8. 停止 Koishi,启用 ChatLuna 1.4,让它自动迁移。

插件配置示例:

plugins:
  chatluna-datamigration: {}

迁移期间不建议同时启用 ChatLuna 1.4:

plugins:
  chatluna: false
  chatluna-datamigration: {}

chatluna-datamigration.run --apply 等同于 purify --apply。 备用直迁方案需要手动执行 shield --apply,再执行 migrate --apply

会清洗的问题

  • 跳过 roomId 无效或模板房间 roomId = 0
  • conversationId 缺失时生成空会话,保留房间配置。
  • updatedTimeupdatedAt 非 Date 时自动修复为可用时间。
  • latestId 指向不存在消息时改选叶子消息,找不到则置空。
  • 重复房间保留更新时间较新的记录。
  • 重复消息生成稳定替代 id。
  • 无效成员、群绑定、用户默认房间记录会跳过并记录 issue。

关于阻止 1.4 自动迁移/删表

  • purify 方案时,不需要阻止 1.4 自动迁移;只要在启用 1.4 之前完成净化即可。
  • 迁移期间仍然不要同时启用 ChatLuna 1.4,否则它可能抢先读到未净化旧表。
  • sentinel 文件只能作为完成标记,不能单独当锁。
  • 如果必须完全阻止 1.4 触碰旧表,使用 shield:它会把 chathub_* 数据移到 chatluna_dm_chathub_*,让 1.4 看不到旧数据。
  • shield + migrate 完成后工具会写入 chatluna_meta.validation_resultroom_migration_donemessage_migration_donelegacy_table_retention = purged 和 sentinel 文件,避免 ChatLuna 1.4 再次触发内置迁移。

备份表默认保留。确认 1.4 正常运行一段时间后,再手动清理 chatluna_dm_* 表。