Documentation
¶
Overview ¶
Package schema is the Ent schema source for ncps. Schemas declared here drive both the generated Ent client (under ent/) and the per-dialect migration files (under migrations/) generated via cmd/generate-migrations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chunk ¶
Chunk holds one row per unique chunk content hash. Chunks are zstd-compressed on disk; `compressed_size` tracks the on-disk byte count. The chunk hash is the Nix base32 representation of the chunk content, 52 characters.
func (Chunk) Annotations ¶
func (Chunk) Annotations() []schema.Annotation
Annotations declares table-level CHECK constraints.
Per the data-model spec: size and compressed_size must be non-negative. CHECK constraints live exclusively in Annotations (invariant A1).
type ConfigEntry ¶
ConfigEntry stores arbitrary key/value configuration (notably the secret signing key) in the `config` table. The Go type name is ConfigEntry because Ent reserves `Config` as a predeclared identifier in its generated client.
func (ConfigEntry) Annotations ¶
func (ConfigEntry) Annotations() []schema.Annotation
Annotations pins the on-disk table name to "config" so the rename of the Go type to ConfigEntry does not change the SQL schema.
type NarFile ¶
NarFile holds one row per unique (hash, compression, query) combination. It tracks both whole-file NARs and CDC-chunked NARs; the CDC state lives in `total_chunks` + `chunking_started_at` (see data-model spec for the state machine).
func (NarFile) Annotations ¶
func (NarFile) Annotations() []schema.Annotation
Annotations declares the on-disk table name (singular Ent default would otherwise be `nar_files` automatically, but we name it explicitly for robustness against Ent's pluralisation rules changing).
type NarFileChunk ¶
NarFileChunk is the ordered-sequence relation between nar_files and chunks for CDC-chunked NARs. ncps's dbmate-era schema used composite PK (nar_file_id, chunk_index); this schema uses a surrogate `id` PK plus a UNIQUE index on (nar_file_id, chunk_index) for the same business invariant — see NarInfoReference for the rationale.
func (NarFileChunk) Annotations ¶
func (NarFileChunk) Annotations() []schema.Annotation
Annotations pins the on-disk table name.
func (NarFileChunk) Indexes ¶
func (NarFileChunk) Indexes() []ent.Index
Indexes of the NarFileChunk.
type NarInfo ¶
NarInfo holds one row per cached .narinfo. Narinfo fields are stored denormalised inline so reads are a single-row lookup. The `url`, `compression`, and related fields MAY be NULL while the narinfo exists in the database as a stub before its full metadata is populated.
func (NarInfo) Annotations ¶
func (NarInfo) Annotations() []schema.Annotation
Annotations pins the on-disk table name to "narinfos" (overriding Ent's default "nar_infos" pluralisation) and declares table-level CHECK constraints.
Per the data-model spec: file_size and nar_size must be non-negative. Field-level entsql.Check annotations are silently dropped by Ent's codegen (invariant A1), so CHECKs live exclusively here.
type NarInfoNarFile ¶
NarInfoNarFile is the M:N join table between narinfos and nar_files. Multiple narinfos can reference the same physical NAR file, and one narinfo MAY reference multiple nar_files when stored in different (compression, query) variants.
func (NarInfoNarFile) Annotations ¶
func (NarInfoNarFile) Annotations() []schema.Annotation
Annotations pins the on-disk table name. See NarInfoReference for why the schema uses a surrogate `id` PK plus a composite UNIQUE index.
func (NarInfoNarFile) Fields ¶
func (NarInfoNarFile) Fields() []ent.Field
Fields of the NarInfoNarFile.
func (NarInfoNarFile) Indexes ¶
func (NarInfoNarFile) Indexes() []ent.Index
Indexes of the NarInfoNarFile mirror the dbmate-era secondary indexes so lookups by either side of the join continue to use an index, plus a composite UNIQUE preserves the original PK uniqueness invariant.
type NarInfoReference ¶
NarInfoReference stores one row per (narinfo, reference) pair — the `References` field of the narinfo expanded across the relation. Primary key is composite on (narinfo_id, reference); there is no surrogate id.
func (NarInfoReference) Annotations ¶
func (NarInfoReference) Annotations() []schema.Annotation
Annotations pins the on-disk table name.
Note: ncps's dbmate-era schema had this table with composite PK (narinfo_id, reference) and no surrogate `id` column. Ent's codegen does not robustly support PK-less entities (see entc/gen "model" template issue with composite-PK entities), so this schema instead adopts a surrogate `id` PK plus a UNIQUE index on (narinfo_id, reference) which preserves the uniqueness invariant.
func (NarInfoReference) Edges ¶
func (NarInfoReference) Edges() []ent.Edge
Edges of the NarInfoReference.
func (NarInfoReference) Fields ¶
func (NarInfoReference) Fields() []ent.Field
Fields of the NarInfoReference.
func (NarInfoReference) Indexes ¶
func (NarInfoReference) Indexes() []ent.Index
Indexes of the NarInfoReference.
type NarInfoSignature ¶
NarInfoSignature stores one row per (narinfo, signature) pair — the `Sig` lines of the narinfo expanded across the relation. Primary key is composite on (narinfo_id, signature).
func (NarInfoSignature) Annotations ¶
func (NarInfoSignature) Annotations() []schema.Annotation
Annotations pins the on-disk table name. See NarInfoReference for why we use a surrogate `id` PK plus a composite UNIQUE index rather than a composite PK.
func (NarInfoSignature) Edges ¶
func (NarInfoSignature) Edges() []ent.Edge
Edges of the NarInfoSignature.
func (NarInfoSignature) Fields ¶
func (NarInfoSignature) Fields() []ent.Field
Fields of the NarInfoSignature.
func (NarInfoSignature) Indexes ¶
func (NarInfoSignature) Indexes() []ent.Index
Indexes of the NarInfoSignature.
type PinnedClosure ¶
PinnedClosure holds one row per pinned narinfo hash. A pinned closure is exempt from LRU eviction.
func (PinnedClosure) Annotations ¶
func (PinnedClosure) Annotations() []schema.Annotation
Annotations declares the on-disk table name.
func (PinnedClosure) Fields ¶
func (PinnedClosure) Fields() []ent.Field
Fields of the PinnedClosure.
func (PinnedClosure) Indexes ¶
func (PinnedClosure) Indexes() []ent.Index
Indexes of the PinnedClosure.