Go to file
tigerenwork 0b7dc0e86e fix: stop orphan reconciliation from killing healthy in-flight runs
Runs now record owner_pid (the Node process that started them) at creation
time. reconcileOrphanRuns skips runs whose owner process is still alive —
previously a newly loaded worker (dev compile / instrumentation) would see a
running run with pid not yet written (during the atlas stage), mark it failed
mid-flight, and disable the stop button, while sling kept running in the
background. Legacy rows with null owner_pid are still reconciled as before.
2026-08-09 23:07:24 +08:00
app feat: stop/cancel running migrations and orphan cleanup on startup 2026-08-09 22:31:25 +08:00
components feat: stop/cancel running migrations and orphan cleanup on startup 2026-08-09 22:31:25 +08:00
docs feat: per-connection URL params and per-pipeline env vars 2026-08-09 18:28:20 +08:00
lib fix: stop orphan reconciliation from killing healthy in-flight runs 2026-08-09 23:07:24 +08:00
public Initial commit from Create Next App 2026-08-09 15:54:43 +08:00
.gitignore feat: local web UI for DB migration via Atlas (schema) + sling (data) 2026-08-09 17:10:17 +08:00
AGENTS.md Initial commit from Create Next App 2026-08-09 15:54:43 +08:00
CLAUDE.md Initial commit from Create Next App 2026-08-09 15:54:43 +08:00
README.md docs: complete prerequisite install instructions for sling and atlas 2026-08-09 20:19:13 +08:00
components.json feat: local web UI for DB migration via Atlas (schema) + sling (data) 2026-08-09 17:10:17 +08:00
eslint.config.mjs Initial commit from Create Next App 2026-08-09 15:54:43 +08:00
instrumentation.ts feat: stop/cancel running migrations and orphan cleanup on startup 2026-08-09 22:31:25 +08:00
next.config.ts feat: local web UI for DB migration via Atlas (schema) + sling (data) 2026-08-09 17:10:17 +08:00
package.json feat: local web UI for DB migration via Atlas (schema) + sling (data) 2026-08-09 17:10:17 +08:00
pnpm-lock.yaml feat: local web UI for DB migration via Atlas (schema) + sling (data) 2026-08-09 17:10:17 +08:00
postcss.config.mjs Initial commit from Create Next App 2026-08-09 15:54:43 +08:00
tsconfig.json Initial commit from Create Next App 2026-08-09 15:54:43 +08:00

README.md

sling-ui

一个本地运行的 Web UI把「测试环境 → 本地 dev 库」的数据同步流程自动化:

  • Schema 迁移Atlas(表 / 索引 / 主外键约束)
  • 数据迁移slingfull-refresh / truncate / incremental / snapshot

第一阶段支持 MySQL / MariaDB / TiDB。

前置依赖

应用本身不内置迁移引擎,需要单独安装以下两个 CLI启动后顶部 banner 会检测是否可用):

  • Node.js 20+ 与 pnpm

  • sling CLI(数据迁移)。需要官方构建conns discover 在 OSS 自编译版不可用):

    # Mac / Linux 一行安装(装到 ~/.sling/bin应用会自动探测该路径
    curl -fsSL https://slingdata.io/install.sh | bash
    
    # 或 Mac 用 brew
    brew install slingdata-io/sling/sling
    

    其他方式见 sling 官方安装文档

  • Atlas CLIschema 迁移,社区版即可):

    # Mac
    brew install ariga/tap/atlas
    
    # Linux
    curl -sSf https://atlasgo.sh | sh
    

    其他方式见 Atlas 安装文档

不需要安装 docker 或 mysql 客户端Atlas 的 dev database 复用目标服务器上的 scratch schemasling_ui_atlas_dev),数据库连接全部走 sling/atlas 自带的驱动。

启动

pnpm install
pnpm dev        # 或 pnpm build && pnpm start

打开 http://localhost:3000

使用流程

  1. Connections:新建源(测试环境)和目标(本地 dev连接点「测试连接」确认可用。
  2. Pipelines → 新建流水线:选源/目标连接、mode、是否开启 schema sync「加载表」勾选要迁移的表。
  3. 流水线详情
    • 「Schema Diff 预览」查看 Atlas dry-run 生成的 DDL
    • 「运行」执行迁移:先 atlas schema apply(同步表结构,含索引/约束),再 sling run(灌数据),日志实时流式展示。
  4. Runs:全部运行历史与日志回放。

mode 说明

  • schema_sync 开启时Atlas 负责目标端表结构;此时即使选择 full-refresh,实际执行会翻译为 truncate(保留 Atlas 建的表结构重灌全量数据,避免 sling drop+重建丢掉索引/约束)。
  • incremental 需要为每张表配置 primary_keyupdate_key
  • sling 连接 URL 自动带 foreign_key_checks=0(会话级),避免外键顺序问题;约束定义本身保留。
  • 连接支持自定义「连接参数」URL query stringsling/Atlas 均生效),流水线支持自定义「环境变量」(写入 replication 的 env:)。

已知问题

  • TiDB 目标库报 Error 8048: isolation level 'SERIALIZABLE' is not supported:见 docs/tidb-serializable-isolation.md,给连接加参数 tidb_skip_isolation_level_check=1 即可。

数据与安全说明

  • 所有应用数据在项目根 data/ 目录(已 gitignoreSQLitesling-ui.db)、生成的 sling env.yaml、replication yaml、运行日志。
  • 连接密码以明文存储在本地 SQLite;运行日志中的命令行已做密码脱敏,但 sling/atlas 自身的输出可能仍含连接信息。本工具定位为本地单人使用,请勿暴露到网络。
  • Atlas 需要一个 dev database 做 schema 规范化:实现为在目标服务器上创建专用 scratch schema sling_ui_atlas_dev(自动创建,保持干净),不依赖 docker。
  • sling 使用应用自管的 home 目录(data/sling-home),不会读写你的 ~/.sling

技术栈

Next.js 16App Router+ TypeScript + Tailwind 4 + shadcn/ui + better-sqlite3通过 shell 调用 sling / atlas 二进制,SLING_LOGGING=JSON 解析结构化日志SSE 实时推送。

路线图

  • PostgreSQL 支持(连接类型 + pg_dump/Atlas 均已抽象)
  • 流水线编辑 UI、定时调度、运行并发队列