package store import ( "context" "fmt" ) func (s *Store) SetForcedUpdate(ctx context.Context, userID, version string) error { _, err := s.pool.Exec(ctx, ` INSERT INTO forced_updates (emby_user_id, version) VALUES ($1, $2) ON CONFLICT (emby_user_id) DO UPDATE SET version = EXCLUDED.version, requested_at = now()`, userID, version) if err != nil { return fmt.Errorf("store: queue forced update: %w", err) } return nil } func (s *Store) ForcedUpdate(ctx context.Context, userID string) (string, error) { var version string err := s.pool.QueryRow(ctx, `SELECT version FROM forced_updates WHERE emby_user_id = $1`, userID).Scan(&version) if isNoRows(err) { return "", nil } if err != nil { return "", fmt.Errorf("store: read forced update: %w", err) } return version, nil } func (s *Store) ClearForcedUpdate(ctx context.Context, userID string) error { _, err := s.pool.Exec(ctx, `DELETE FROM forced_updates WHERE emby_user_id = $1`, userID) if err != nil { return fmt.Errorf("store: clear forced update: %w", err) } return nil }