Menu

1 / 2

Modeling a two-signature record in Postgres: one person marks, the other confirms

DEV Community: postgres·Raj Bhadane·about 18 hours ago
#QSJQgXWz
#devtopostgresql#devto#dev#waiting#marks
Long article (737 words) — no AI summary yet.
Reading 0:00
15s threshold

I'm building Commitment, a small Android app (iOS is in review) for counts that two people share: milk deliveries, a maid's attendance, money lent to a friend, a gym streak. The whole product is one rule: an entry only counts once the other person confirms it.

That rule turned out to be a nice little data-modeling problem. Here is how it ended up in Postgres on Supabase, with the actual constraints from the migration.

The mark table

Every "this happened" is a row in marks , with a small state machine in a check constraint:

create table public . marks ( id uuid primary key default gen_random_uuid ( ) , commitment_id uuid not null references public . commitments ( id ) on delete cascade , day date not null , marked_by uuid not null references public . profiles ( id ) on delete cascade , marked_at timestamptz not null default now ( ) , status text not null default 'waiting' check ( status in ( 'waiting' , 'confirmed' , 'rejected' , 'expired' ) ) , responded_by uuid references public .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.