Help us shape the future of Go! Take the 2026 Go Developer Survey

refsettle

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package refsettle settles the rows whose reference points at a row that is gone, and then validates the foreign keys a migration added NOT VALID (ADR 0033: a migration only adds, the heavy data work runs afterwards). The references date from before they were foreign keys (an Erasure, an erased Template): a row either goes with the row it named (it died with it) or only the dangling id goes (it outlives it), the way the key's `ON DELETE` would have. A new write cannot dangle, since the keys are enforced from the migration on, so once a key is validated every run finds nothing.

The settling reads and writes every Workspace's rows, so the module holds the raw ent client. The jobs only call it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Settler

type Settler struct {
	// contains filtered or unexported fields
}

Settler settles dangling references on the raw ent client.

func New

func New(client *ent.Client) *Settler

New builds a Settler over the raw client.

func (*Settler) ClearContactRefs

func (s *Settler) ClearContactRefs(ctx context.Context, batch int) (int, error)

ClearContactRefs settles, table by table, the rows that name a Contact which is gone (at most batch rows per step, so no long lock; a run interrupted halfway finishes on the next), and validates each key that is still NOT VALID once its table is clean. It returns how many rows it settled.

func (*Settler) ClearOutboundMessageRefs

func (s *Settler) ClearOutboundMessageRefs(ctx context.Context, batch int) (int, error)

ClearOutboundMessageRefs clears, reference by reference, the ids of Outbound messages that point at nothing (at most batch rows per step, so no long lock; a run interrupted halfway finishes on the next), and validates each key that is still NOT VALID once its column is clean. It returns how many ids it cleared. A message keeps everything else: only the dangling id goes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL