Demo DB: feature-rich seed (12 objects, 500-row audit log) + regenerate action in Settings

- Expand demo schema to exercise every SQLite-available feature: composite PK
  (order_items), self-referencing FK (categories), JSON columns (lowercase
  'json' so the cell popover triggers), BLOBs (files), no-PK table (page_views,
  rowid editing), TEXT PK (app_settings), empty table (marketing_campaigns),
  read-only view (order_summary), CHECK/UNIQUE/defaults/indexes, smart-sort
  tiers, and a 500-row audit_log for pagination/virtualization/filter demos
- Stamp PRAGMA user_version = 2; stale demo files auto-recreate on launch
  (schema is idempotent, guarded inserts)
- Add regenerate_demo_db command: drops live pool handle, wipes + re-seeds
  the demo file; new Settings > General > Demo 'Regenerate demo' button with
  confirm dialog, loading state, toasts
- Fix Re-add demo to use the app data dir (was temp dir) so both paths match
  startup; reload connections after re-add
- Add 9 unit tests (demo.test.rs) covering objects, seed counts, JSON
  validity, FK consistency, view queryability, idempotency, constraint
  shapes, and stale/regenerate file flows
This commit is contained in:
2026-08-03 19:00:21 +08:00
parent 16888460b7
commit a9dbf60ed5
7 changed files with 702 additions and 159 deletions
+1 -1
View File
@@ -251,7 +251,7 @@ gridline/
- **Phase 4 — Data Grid & Filters** — Virtualized grid (`@tanstack/react-virtual`, 100k+ rows), server-side sorting/filtering, column show/hide, column resize, export (JSON/CSV/SQL/Markdown), auto-refresh, pagination
- **Phase 5 — Admin Tools** — `pg_dump`/`pg_restore` UI wrappers with real-time progress, DB-to-DB sync, backup/restore format selectors
- **Phase 6 — Schema Visualizer** — Interactive ER diagram with React Flow + dagre, crow's foot notation, schema selector, legend, collapsible column views, PostgreSQL + SQLite support
- **Home Screen & Organization** — Connection cards by folder, folders CRUD, tags CRUD with colors, global search (Cmd+K), import/export connections (JSON), bulk select/delete, DB type filter, demo SQLite database
- **Home Screen & Organization** — Connection cards by folder, folders CRUD, tags CRUD with colors, global search (Cmd+K), import/export connections (JSON), bulk select/delete, DB type filter, feature-rich demo SQLite database (12 objects incl. a view, 500-row audit table, JSON/BLOB/composite-PK/no-PK/empty tables) with re-add + regenerate actions in Settings
- **Query Editor (Core)** — Monaco SQL editor with Cmd+Enter execution, `execute_query` Rust command (PostgreSQL + SQLite, subquery pagination with raw fallback), query tabs in the DB viewer, destructive query confirmation dialog, `query_history` persistence backend
- **Home Screen Filters** — Tag filter with OR semantics, folder cards matching tags or containing matching connections, DB type filter hiding empty folders, environment filter (All/Production/Staging/Development/None), global search across all folders with "Showing Search Results" breadcrumb + Clear
- **Query History & Saved Queries** — toolbar history dropdown (load / run / favorite / clear), favorites, consecutive-identical dedup + 500-retention pruning, SaveQueryDialog, and a two-pane Queries view (History / Saved Queries sidebar scoped per connection + tabbed query workspace)