| 1 | -- A like is a fact: who liked which post. |
| 2 | create table likes ( |
| 3 | post_id bigint not null references posts (id), |
| 4 | user_id bigint not null references users (id), |
| 5 | created_at timestamptz not null default now(), |
| 6 | primary key (post_id, user_id) |
| 7 | ); |
| 8 | |
| 9 | alter table posts add column likes_count integer not null default 0; |