mirror of
https://github.com/lobehub/lobe-chat.git
synced 2026-06-14 03:30:19 +00:00
caa7905be2
* 🔨 feat(db): batch topic usage stats, push tokens, tasks editor_data & document shares
Bundle four independent schema changes onto one migration branch:
- 0104 topics: add usage/cost aggregate columns (total_cost, token totals,
cost/usage jsonb, model, provider) + model/provider indexes
- 0105 push_tokens: new table for Expo push notification tokens
- 0106 tasks: add editor_data jsonb column
- 0107 document_shares: new table for document share flow
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* 🔨 chore(db): combine batch schema changes into a single migration
Squash the four sequential migrations (0104-0107) into one 0104 SQL file
containing all DDL: topic usage/cost columns, push_tokens table,
tasks.editor_data column, and document_shares table.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* 🔨 chore(db): make push_tokens unique constraint device-only
Drop the userId prefix from the push_tokens unique index — one row per
device, reassigned to the new user on switch (upsert by deviceId).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* ✨ feat(db): add user_connectors and user_connector_tools schema
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* ✨ feat(db): add user_connectors and user_connector_tools schema
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* ♻️ refactor(db): merge connectorTool schema into connector.ts
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* ⏪ revert(db): restore push_tokens unique constraint to (userId, deviceId)
This reverts commit addf14c2a6 (device-only unique index).
The device-only index conflicts with #15186's pushToken upsert, whose
onConflict target is (userId, deviceId). Restore the composite unique
index so the upsert lands consistently with both PRs.
Also re-point 0105 snapshot prevId to the restored 0104 id and carry the
(userId, deviceId) index forward so the migration chain stays consistent.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* ✨ feat(db): add devices table and consolidate batch migration into 0104
Add the `devices` identity anchor (surrogate uuid PK + unique(userId, deviceId))
as the stable, reinstall-proof base for binding agent runtime instances per
machine. Fold the prior 0104/0105 migrations and the new table into a single
idempotent 0104 migration.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* ✅ test(db): add topic usage/cost columns to topic.create assertions
The batch added 8 nullable topic columns (totalCost/usage/model/...) but
topic.create.test.ts still asserted the pre-batch 19-field shape via toEqual.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* ♻️ refactor(db): use uuid primary key for document_shares
Align document_shares.id with the other new batch tables (uuid defaultRandom);
table has no consumers yet so no compat impact. Regenerated 0104 + snapshot.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Co-authored-by: ONLY-yours <1349021570@qq.com>