`river_queue.updated_at` should be `NOT NULL` with a default, or nullable
An oddity I noticed while working on #870 in river_queue:
CREATE TABLE river_queue (
name text PRIMARY KEY NOT NULL,
created_at timestamptz NOT NULL DEFAULT now(),
metadata jsonb NOT NULL DEFAULT '{}' ::jsonb,
paused_at timestamptz,
updated_at timestamptz NOT NULL
);
updated_at is non-nullable, but also doesn't apply a default. That means that if you inserted a row without including a value for it, the insert would fail.
This is pretty weird. It should be one of:
- Non-nullable but with a default, similar to
created_at. So like:updated_at timestamptz NOT NULL DEFAULT now(). - Nullable (you could make the case that
updated_atshouldn't be set on insert, and rather than only the first time it's updated after insert).
Probably (1) is better out of these two options.
This also applies to river_client and river_client_queue where the problem was copy/pasta'ed from river_queue, but these ones matter less because we'll probably end up dropping them anyway.
Filed this under "needs db migration" so on the next migration we can burn through that list and just get everything in one go.
I want to say I ran into issues with having this originally, perhaps due to the COPY FROM bulk insert.