一个零依赖、超轻量级的 SQLite 数据库时间机器。
A zero-dependency, ultra-lightweight database time machine for SQLite

原始链接: https://github.com/nsrht/time-travel-sqlite-debugger

这是一个开源、超轻量级的工具,允许开发人员在本地开发过程中对 SQLite 数据库状态进行“时间旅行”。它采用纯 PHP 8+ 和原生 JavaScript 构建,无需任何依赖或重型框架。 **主要功能:** * **自动快照:** CLI 守护进程会跟踪数据库更改(包括 WAL 模式)并自动保存带有时间戳的备份。 * **直观的 UI:** 通过可视化滑块或快捷键,像操作视频一样浏览数据库历史记录。 * **智能分析:** 内置可视化差异查看器,可在恢复前检查表更改和行数。 * **管理功能:** 可轻松固定重要快照以防止自动删除,将特定状态导出为 `.sqlite` 文件,并通过自动清理机制管理磁盘空间。 * **国际化支持:** 语言文件完全解耦,支持动态多语言(已包含英语/土耳其语)。 **用法:** 只需运行守护进程和 Web 界面即可监控您的数据库。无论是在调试还是测试中,它都能提供一种无缝的方式,将损坏或修改的数据恢复到之前的任何时间点。该工具具有高度可移植性,易于翻译,并以 MIT 许可证分发。

抱歉。
相关文章

原文

An open-source, ultra-lightweight web application and CLI daemon designed to track and instantly rewind a corrupted or modified SQLite database file back to any previous state (e.g. 3 minutes ago) during local development — just like scrubbing a video.

🇹🇷 Türkçe Dokümantasyon: Türkçe rehber için lütfen README.tr.md dosyasına bakın.


  • ⚡ Zero Dependencies: Built with pure PHP 8+ and Vanilla JS. Requires no heavy frameworks or npm packages.
  • 🌐 Full i18n / Multi-Language: Translation files are completely decoupled in lang/. Switch languages dynamically from the UI (e.g., 🇹🇷 Turkish, 🇬🇧 English). Easily contribute by adding or updating lang/xx.json files.
  • 💾 SQLite WAL Mode Aware: Seamlessly backs up and restores .sqlite-wal and .sqlite-shm files for databases running PRAGMA journal_mode=WAL;.
  • 🔍 Visual Data & Table Diff Viewer: Compare row counts and table changes (+3 rows in live) between any historic snapshot and your current live database before restoring.
  • 📌 Snapshot Pinning & Tagging: Pin important snapshots with one click to protect them from auto-cleanup.
  • 📥 One-Click Snapshot Export: Download any historic database state directly as a .sqlite file.
  • ⌨️ Keyboard Navigation Shortcuts: Navigate through the timeline smoothly using Left Arrow (⬅️) and Right Arrow (➡️) keys.
  • 🔄 Automatic Instant Snapshots (Watcher Daemon): Background CLI script (watcher.php) listens for modifications in database.sqlite and automatically creates timestamped snapshots (backups/1715000000_database.sqlite).
  • 🧹 Automatic Cleanup: Maintains up to 50 backups, purging older unpinned snapshots to prevent disk clutter.

time-travel/
├── index.html        # Chrono Console UI (Tailwind CSS + Vanilla JS + i18n Engine)
├── api.php           # Snapshot listing, restoration, diff, export, and i18n API
├── watcher.php       # CLI background listener daemon script (WAL & signal aware)
├── lang.php          # Multi-language (i18n) helper class
├── lang/             # JSON language files directory
│   ├── tr.json       # Turkish language file
│   └── en.json       # English language file
├── database.sqlite   # Target SQLite database file (created automatically)
├── backups/          # Timestamped backups directory (created automatically)
├── README.md         # Primary English documentation
└── README.tr.md      # Turkish documentation & guide

🌍 Translation Guide: Adding & Updating Language Files

Create a JSON file inside lang/ matching the ISO code (e.g., lang/es.json, lang/de.json):

{
  "code": "es",
  "name": "Español",
  "flag": "🇪🇸",
  "cli": { ... },
  "api": { ... },
  "ui":  { ... }
}

2. Updating Existing Translations

Open any file in lang/*.json and edit strings. Changes reflect immediately on the Web UI and CLI without restarting the server.


💻 Installation & Usage

1. Start the Watcher Daemon (Terminal 1)

To specify custom language or database file:

php watcher.php database.sqlite en

2. Start Local Web Server (Terminal 2)

Open your browser and navigate to: http://127.0.0.1:8000


  1. Open the web interface.
  2. Click "✍️ Add Test Data (DB Write)".
  3. Observe terminal output from watcher.php: [+] Created snapshot: 1715000000_database.sqlite
  4. Drag the timeline slider or use ⬅️ / ➡️ arrow keys.
  5. Click "🔍 Compare Diff" to inspect table row changes.
  6. Click "⚡ Restore To This State" to rewind your database!

🔒 File Permissions (Linux / Unix)


This project is open-source under the MIT license.

联系我们 contact @ memedata.com