mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 07:13:29 +00:00
feat(integrations): remove the moodLog integration
Mood has been a first-class module here for a long time, with entries,
structured tags, rated factors and notes. The bridge to the external moodLog
service had nothing left to add, and its Settings card was withdrawn in
a56e6fe61 on the promise of a dedicated removal. This delivers it.
Removed: the hourly `moodlog-sync` queue, cron and handler binding; the
inbound webhook and its shared-secret handling; the reverse push and its four
call sites; the pull-sync module; the per-user credential routes and the
instance-wide toggle; the entry on the `/api/integrations/status` envelope,
the `IntegrationKey` union, the cadence map and the display-name table; the
boot-time secret rotation pass; 22 message keys per locale.
Migration 0271 drops the five `users` credential columns and
`app_settings.mood_log_global`, clears the ledger row for the provider, and
deletes the retired pg-boss schedule so no cron keeps enqueuing work no
handler drains.
Mood data is untouched. `mood_entries` is not named anywhere in the migration
and cannot be reached from it: the dropped columns carry no index, constraint
or foreign key, and `mood_entries.user_id` references `users(id)`, not any of
them. Rows the bridge imported keep `source = 'MOODLOG'`, and every read path
- list filter, source badge, exports, backups - still resolves that value.
`src/lib/validations/moodlog.ts` held the native mood-entry schemas alongside
the bridge's own; it is now `validations/mood.ts` and carries only the former.
This commit is contained in:
1 parent
4ed8c8f39b
commit
d0b45e36b3
106 files changed
+379
-3326
No files matched your search
@@ -0,0 +1,64 @@
|
||||
-- v1.32.33 — retire the moodLog integration.
|
||||
--
|
||||
-- The bridge to the external moodLog service is gone: no pull cron, no
|
||||
-- inbound webhook, no reverse push, no settings or admin surface. What this
|
||||
-- migration removes is the integration's own state and nothing else.
|
||||
--
|
||||
-- DATA BOUNDARY — read before editing.
|
||||
--
|
||||
-- `mood_entries` is NOT touched. Mood is a first-class HealthLog module and
|
||||
-- every row in that table is the user's own health record, including the rows
|
||||
-- the bridge imported (they carry `source = 'MOODLOG'` and keep it, so the
|
||||
-- mood list still labels them honestly). Nothing below names `mood_entries`,
|
||||
-- and nothing below can reach it:
|
||||
--
|
||||
-- * The six dropped columns are plain scalars on `users` / `app_settings`.
|
||||
-- None carries an index, a unique, a check or a foreign key (see
|
||||
-- migration 0014, which added all six), so `DROP COLUMN` rewrites those
|
||||
-- two tables' tuples and stops there. `DROP COLUMN` never cascades into
|
||||
-- another table on its own, and there is no CASCADE keyword here.
|
||||
-- * `mood_entries.user_id` references `users(id)`, not any dropped column.
|
||||
-- Dropping a non-referenced column leaves that foreign key intact and
|
||||
-- leaves every mood row addressable.
|
||||
-- * The `integration_statuses` delete is scoped by `integration = 'moodlog'`
|
||||
-- — sync-ledger bookkeeping for a provider that no longer exists. That
|
||||
-- table holds no health values and nothing references it.
|
||||
--
|
||||
-- The pg-boss cleanup is guarded on the schema existing: the worker owns that
|
||||
-- schema and creates it at boot, so a first-install database runs this
|
||||
-- migration before `pgboss` exists. Without it, a live instance would keep an
|
||||
-- hourly `moodlog-sync` schedule enqueuing work no handler drains.
|
||||
|
||||
-- Stop the retired cron and drain anything it already queued.
|
||||
DO $$
|
||||
BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.tables
|
||||
WHERE table_schema = 'pgboss' AND table_name = 'schedule'
|
||||
) THEN
|
||||
DELETE FROM pgboss.schedule WHERE name = 'moodlog-sync';
|
||||
END IF;
|
||||
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.tables
|
||||
WHERE table_schema = 'pgboss' AND table_name = 'job'
|
||||
) THEN
|
||||
DELETE FROM pgboss.job WHERE name = 'moodlog-sync';
|
||||
END IF;
|
||||
END
|
||||
$$;
|
||||
|
||||
-- Sync-ledger row for the retired provider.
|
||||
DELETE FROM "integration_statuses" WHERE "integration" = 'moodlog';
|
||||
|
||||
-- Per-user credentials and the enable flag.
|
||||
ALTER TABLE "users"
|
||||
DROP COLUMN IF EXISTS "mood_log_url_encrypted",
|
||||
DROP COLUMN IF EXISTS "mood_log_api_key_encrypted",
|
||||
DROP COLUMN IF EXISTS "mood_log_enabled",
|
||||
DROP COLUMN IF EXISTS "mood_log_last_synced_at",
|
||||
DROP COLUMN IF EXISTS "mood_log_webhook_secret";
|
||||
|
||||
-- Instance-wide kill switch for the retired integration.
|
||||
ALTER TABLE "app_settings"
|
||||
DROP COLUMN IF EXISTS "mood_log_global";
|
||||
+11
-15
@@ -233,13 +233,6 @@ model User {
|
||||
// predicate `strava_backfill_completed_at IS NULL`), mirroring WHOOP/Fitbit.
|
||||
stravaBackfillCompletedAt DateTime? @map("strava_backfill_completed_at")
|
||||
|
||||
// moodLog integration (per-user, encrypted)
|
||||
moodLogUrlEncrypted String? @map("mood_log_url_encrypted")
|
||||
moodLogApiKeyEncrypted String? @map("mood_log_api_key_encrypted")
|
||||
moodLogEnabled Boolean @default(false) @map("mood_log_enabled")
|
||||
moodLogLastSyncedAt DateTime? @map("mood_log_last_synced_at")
|
||||
moodLogWebhookSecret String? @map("mood_log_webhook_secret")
|
||||
|
||||
// Locale (null = use system/admin default)
|
||||
locale String? @map("locale") // "de" | "en" | null
|
||||
|
||||
@@ -3755,7 +3748,7 @@ model GoogleHealthOAuthState {
|
||||
@@map("google_health_oauth_states")
|
||||
}
|
||||
|
||||
// ─── Mood Entries (moodLog) ───────────────────────────────────
|
||||
// ─── Mood Entries ─────────────────────────────────────────────
|
||||
|
||||
model MoodEntry {
|
||||
id String @id @default(cuid())
|
||||
@@ -3781,11 +3774,15 @@ model MoodEntry {
|
||||
/// IllnessDayLog / CycleDayLog / LabResult note convention). Registered in
|
||||
/// ENCRYPTED_COLUMNS + the rotation script.
|
||||
noteEncrypted Bytes? @map("note_encrypted")
|
||||
source String @default("MOODLOG") // WEB, TELEGRAM, DAYLIO
|
||||
// Provenance. MANUAL / WEB / TELEGRAM / DAYLIO / MCP, plus the legacy
|
||||
// MOODLOG value carried by rows the retired moodLog bridge imported —
|
||||
// those rows are user history and keep their label. The column default
|
||||
// is legacy too; every writer sets `source` explicitly.
|
||||
source String @default("MOODLOG")
|
||||
// v1.12.1 — stable per-source dedup id. NULL for native / MANUAL
|
||||
// entries (those dedup on the legacy `(userId, date, moodLoggedAt)`
|
||||
// key). When an importer receives a source-stable id (the moodLog
|
||||
// upstream entry id, a Daylio row id) it writes it here and upserts on
|
||||
// key). When an importer receives a source-stable id (an iOS row
|
||||
// UUID, a Daylio row id) it writes it here and upserts on
|
||||
// `@@unique([userId, source, externalId])`, so a re-import is
|
||||
// idempotent even when `moodLoggedAt` re-rounds / re-zones. Postgres
|
||||
// treats NULLs as distinct in that unique, so MANUAL rows never
|
||||
@@ -3859,7 +3856,7 @@ model MoodEntry {
|
||||
//
|
||||
// Backward-compat: this is purely ADDITIVE. The legacy flat
|
||||
// `MoodEntry.tags` (a JSON string array of free-text keys) keeps working
|
||||
// unchanged — the GLP-1 quick-tag chips, the Telegram/MoodLog sync, and
|
||||
// unchanged — the GLP-1 quick-tag chips, the Telegram capture, and
|
||||
// every existing row stay on the flat axis. The structured taxonomy is a
|
||||
// second, richer capture surface that the tag-frequency / lift breakdown
|
||||
// folds in next to the flat tags (`mood-aggregates.ts`).
|
||||
@@ -4095,12 +4092,12 @@ model MedicationComplianceRollup {
|
||||
// (the sync entry-points consult this row before doing any external
|
||||
// work).
|
||||
//
|
||||
// `integration` values are bare strings ("withings", "moodlog") rather
|
||||
// `integration` values are bare strings ("withings", "whoop") rather
|
||||
// than an enum so future integrations don't require a migration.
|
||||
model IntegrationStatus {
|
||||
id String @id @default(cuid())
|
||||
userId String @map("user_id")
|
||||
integration String // "withings" | "moodlog"
|
||||
integration String // "withings" | "whoop" | "fitbit" | …
|
||||
state String @default("connected") // "connected" | "error_reauth" | "error_transient" | "disconnected" | "parked"
|
||||
lastSuccessAt DateTime? @map("last_success_at")
|
||||
lastAttemptAt DateTime? @map("last_attempt_at")
|
||||
@@ -4143,7 +4140,6 @@ model AppSettings {
|
||||
webPushVapidPrivateKeyEncrypted String? @map("web_push_vapid_private_key_encrypted")
|
||||
webPushVapidSubject String? @map("web_push_vapid_subject")
|
||||
apiGlobal Boolean @default(true) @map("api_global") // global toggle
|
||||
moodLogGlobal Boolean @default(true) @map("mood_log_global")
|
||||
umamiEnabled Boolean @default(false) @map("umami_enabled")
|
||||
umamiScriptUrl String? @map("umami_script_url")
|
||||
umamiWebsiteId String? @map("umami_website_id")
|
||||
|
||||
Reference in new issue
Block a user