steid

@jamesgill /

steid/migrations/20260906120300_create_push_events.sql
SQL1.3 KBCode·Blame·History·Raw
1-- Push events: one row per ref that changed, per authorized push.
2--
3-- Recorded from the application after the receive-pack RPC completes, not from a
4-- `post-receive` hook script inside the bare repository — Steid already knows who the
5-- actor is at that point, and a hook script would have to be installed on creation and
6-- on boot, kept in sync with the binary, and given a channel back into the process.
7--
8-- Never deleted. This is a record that something happened; rows go only when the
9-- repository does.
10--
11-- `before_id` is the all-zero object id for a ref that was created, and `after_id` is
12-- for one that was deleted — git's own convention, so a payload can be handed to a
13-- receiver that already understands it.
14create table push_events (
15 id text primary key,
16 repo_id text not null references repositories (id) on delete cascade,
17 ref_name text not null,
18 before_id text not null,
19 after_id text not null,
20 -- Null only once the pushing user is deleted: pushes are always authorized, so
21 -- there is no anonymous case for this to represent.
22 pusher_id text references users (id) on delete set null,
23 created_at integer not null
24);
25
26-- The listing every consumer makes: a repository's recent events, newest first.
27create index push_events_repo_id on push_events (repo_id, created_at desc);