Skip to content

river_queue.updated_at should be NOT NULL with a default, or nullable #874

Closed

Description

@brandur

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:

  1. Non-nullable but with a default, similar to created_at. So like: updated_at timestamptz NOT NULL DEFAULT now().
  2. Nullable (you could make the case that updated_at shouldn'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.

Activity

  1. brandur commented on May 3, 2025

    @brandur
    ContributorAuthor

    Filed this under "needs db migration" so on the next migration we can burn through that list and just get everything in one go.

  2. bgentry commented on May 4, 2025

    @bgentry
    Contributor

    I want to say I ran into issues with having this originally, perhaps due to the COPY FROM bulk insert.

  3. added 2 commits that reference this issue on Dec 26, 2025
    b4d68e0
    e2e7566
  4. added a commit that references this issue on Jun 11, 2026
    65f1c1f
  5. added a commit that references this issue on Jun 11, 2026
    751f4c4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs db migrationFixing this issue would require a new database migration

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions