Skip to content

Add updated_at trigger to the artists table #38

@chiptus

Description

@chiptus

Problem

The artists table has no updated_at trigger. Every other table that has an updated_at column gets one via update_updated_at_column()sets, groups, stages, festivals, festival_editions, festival_info, custom_links, artist_notes, soundcloud — but artists was missed.

artists.updated_at has DEFAULT now(), which only applies on INSERT, not UPDATE. As a result, application code has to set updated_at manually on every update (see src/hooks/queries/artists/useUpdateArtist.ts), and any update path that forgets to do so leaves the timestamp stale.

Suggested fix

Add a migration creating the missing trigger, matching the other tables:

CREATE TRIGGER update_artists_updated_at
  BEFORE UPDATE ON public.artists
  FOR EACH ROW
  EXECUTE FUNCTION public.update_updated_at_column();

Once the trigger exists, drop the manual updated_at: new Date().toISOString() line from updateArtist in useUpdateArtist.ts so the DB is the single source of truth.

Context

Came up during PR #34 review. The equivalent redundant line in useUpdateSet.ts was already removed there (the sets table already has its trigger). Tracking the artists trigger separately since it is a schema change unrelated to the db-sync PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions