tasks now update streaks in db

This commit is contained in:
masongga
2026-05-23 22:12:00 -06:00
parent f51b73bec4
commit 53f3cec385
3 changed files with 79 additions and 29 deletions

View File

@@ -0,0 +1,13 @@
-- Remove duplicate active habits with the same name for a user.
delete from public.habits duplicate
using public.habits keeper
where duplicate.user_id = keeper.user_id
and duplicate.name = keeper.name
and duplicate.active = true
and keeper.active = true
and duplicate.id <> keeper.id
and duplicate.created_at > keeper.created_at;
create unique index if not exists habits_user_id_name_active_unique
on public.habits (user_id, name)
where active = true;