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
+3 -2
View File
@@ -315,8 +315,9 @@ cargo test # Rust tests
### Demo & Onboarding
| Feature | Status | Details |
| :--- | :---: | :--- |
| Demo SQLite database (auto-seeded) | ✅ | users, products, orders, order_items tables |
| Re-add demo DB button | ✅ | Settings → Advanced |
| Demo SQLite database (auto-seeded) | ✅ | Feature-rich e-commerce demo (SQLite) exercising every SQLite-available feature: users/products/categories (self-FK)/addresses/orders/order_items (composite PK)/audit_log (500 rows, pagination + virtualization + JSON `details`)/files (BLOB)/page_views (no PK → rowid editing)/app_settings (TEXT PK)/marketing_campaigns (empty → Empty Table change)/order_summary VIEW. JSON columns declared lowercase `json` (popover works), CHECK/UNIQUE/defaults/indexes surface in copied DDL, smart-sort tiers covered (updated_at/created_at/last_login_at/*_id/quantity), nullable FKs + long text for the smart editors. Version-stamped via `PRAGMA user_version`; stale demo files auto-recreate on launch |
| Re-add demo DB button | ✅ | Settings → General → Demo; re-creates the connection (same app-data-dir file as startup) |
| Regenerate demo DB button | ✅ | Settings → General → Demo; confirm dialog, drops the live pool handle, wipes + re-seeds the demo file (clears any edits made against the demo) |
| Getting started / onboarding flow | ❌ | |
| Welcome tooltips / tour | ❌ | |