Repository navigation
Add Habit Tracker example: Next.js, Drizzle ORM and ClickHouse Managed Postgres - #504
Merged
Merged
Conversation
…d Postgres A Next.js 16 habit tracker (Server Components, Server Actions, Click UI) using Drizzle ORM with node-postgres on ClickHouse Managed Postgres, provisioned with clickhousectl. A (habit_id, day) primary key and INSERT ... ON CONFLICT DO NOTHING keep one check-in per habit per day under retries and concurrency; streaks use a gaps-and-islands query. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lio-p
approved these changes
Oct 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
applications/habit-tracker: a Next.js 16 habit tracker (App Router, Server Components, Server Actions, Click UI) using Drizzle ORM with node-postgres on ClickHouse Managed Postgres, provisioned withclickhousectl.Database lesson: one check-in per habit per day.
check_inshas a(habit_id, day)primary key. The checkbox sends its desired state rather than a toggle, and checking a day is a singleINSERT … SELECT … ON CONFLICT DO NOTHING, so double clicks, retries and concurrent requests leave one row. Streaks are computed in SQL with a gaps-and-islands window query.Included: the app,
src/db.tswith verify-full TLS from the service CA (it refuses a remote host without a CA), drizzle-kit migrations, SQL for roles, grants, seed and cleanup, unit and integration tests, a README with everyclickhousectlandpsqlstep, a CI workflow (install, typecheck and unit tests, build), and one line in the root README.Verified against ClickHouse Managed Postgres 18.6:
23505, idempotent unchecking, streaks across gaps, ownership and archive checks, app-role DDL failing with42501, andpg_stat_sslreporting TLS.Walkthrough article (production URL): https://clickhouse.com/resources/engineering/build-habit-tracker-nextjs-drizzle-postgres
🤖 Generated with Claude Code