| 1 | create table users ( |
| 2 | id bigint generated always as identity primary key, |
| 3 | handle text not null unique, |
| 4 | token_hash bytea not null unique, |
| 5 | created_at timestamptz not null default now() |
| 6 | ); |
| 7 | |
| 8 | create table posts ( |
| 9 | id bigint generated always as identity primary key, |
| 10 | user_id bigint not null references users (id), |
| 11 | body text not null check (char_length(body) between 1 and 280), |
| 12 | created_at timestamptz not null default now() |
| 13 | ); |
| 14 | |
| 15 | create index posts_user_id_id_idx on posts (user_id, id desc); |