schema

package
v0.10.0-rc9 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 8 Imported by: 0

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 BuildTraceEntry

type BuildTraceEntry struct {
	ent.Schema
}

BuildTraceEntry holds one row per stored build-trace-v2 entry. A build trace entry maps a (drv_path, output_name) key to an out_path value, signed by one or more parties. raw_json stores the verbatim upload body as a forward-compatibility safety valve.

func (BuildTraceEntry) Annotations

func (BuildTraceEntry) Annotations() []schema.Annotation

Annotations pins the on-disk table name to "build_trace_entries".

func (BuildTraceEntry) Edges

func (BuildTraceEntry) Edges() []ent.Edge

Edges of the BuildTraceEntry.

func (BuildTraceEntry) Fields

func (BuildTraceEntry) Fields() []ent.Field

Fields of the BuildTraceEntry.

func (BuildTraceEntry) Indexes

func (BuildTraceEntry) Indexes() []ent.Index

Indexes of the BuildTraceEntry.

func (BuildTraceEntry) Mixin

func (BuildTraceEntry) Mixin() []ent.Mixin

Mixin of BuildTraceEntry.

type BuildTraceSignature

type BuildTraceSignature struct {
	ent.Schema
}

BuildTraceSignature stores one row per (build_trace_entry, signature) pair. key_name is the signing key identifier (e.g. "cache.example.com-1"); signature is the base64-encoded Ed25519 signature over the entry fingerprint.

func (BuildTraceSignature) Annotations

func (BuildTraceSignature) Annotations() []schema.Annotation

Annotations pins the on-disk table name to "build_trace_signatures".

func (BuildTraceSignature) Edges

func (BuildTraceSignature) Edges() []ent.Edge

Edges of the BuildTraceSignature.

func (BuildTraceSignature) Fields

func (BuildTraceSignature) Fields() []ent.Field

Fields of the BuildTraceSignature.

func (BuildTraceSignature) Indexes

func (BuildTraceSignature) Indexes() []ent.Index

Indexes of the BuildTraceSignature.

type Chunk

type Chunk struct {
	ent.Schema
}

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).

func (Chunk) Edges

func (Chunk) Edges() []ent.Edge

Edges of the Chunk.

The nar_file_chunks back-reference is intentionally exposed as a plain edge (not Through) because the join table's PK is on (nar_file_id, chunk_index), not on the FK columns — see NarFile.Edges.

func (Chunk) Fields

func (Chunk) Fields() []ent.Field

Fields of the Chunk.

func (Chunk) Indexes

func (Chunk) Indexes() []ent.Index

Indexes of the Chunk.

func (Chunk) Mixin

func (Chunk) Mixin() []ent.Mixin

Mixin of Chunk.

type ConfigEntry

type ConfigEntry struct {
	ent.Schema
}

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.

func (ConfigEntry) Fields

func (ConfigEntry) Fields() []ent.Field

Fields of the ConfigEntry.

func (ConfigEntry) Indexes

func (ConfigEntry) Indexes() []ent.Index

Indexes of the ConfigEntry.

func (ConfigEntry) Mixin

func (ConfigEntry) Mixin() []ent.Mixin

Mixin of ConfigEntry.

type NarFile

type NarFile struct {
	ent.Schema
}

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).

func (NarFile) Edges

func (NarFile) Edges() []ent.Edge

Edges of the NarFile.

Both narinfo_nar_files and nar_file_chunks are modelled as plain edges to their join entities (not Ent's Through pattern) because the join entities use surrogate `id` PKs.

func (NarFile) Fields

func (NarFile) Fields() []ent.Field

Fields of the NarFile.

func (NarFile) Indexes

func (NarFile) Indexes() []ent.Index

Indexes of the NarFile.

func (NarFile) Mixin

func (NarFile) Mixin() []ent.Mixin

Mixin of NarFile.

type NarFileChunk

type NarFileChunk struct {
	ent.Schema
}

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) Edges

func (NarFileChunk) Edges() []ent.Edge

Edges of the NarFileChunk.

func (NarFileChunk) Fields

func (NarFileChunk) Fields() []ent.Field

Fields of the NarFileChunk.

func (NarFileChunk) Indexes

func (NarFileChunk) Indexes() []ent.Index

Indexes of the NarFileChunk.

type NarInfo

type NarInfo struct {
	ent.Schema
}

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.

func (NarInfo) Edges

func (NarInfo) Edges() []ent.Edge

Edges of the NarInfo.

The narinfo<->nar_file M:N is modelled as a plain edge to the NarInfoNarFile join entity (rather than Ent's Through pattern) because the join entity uses a surrogate `id` PK with a composite UNIQUE index, not a composite PK on the FK columns.

func (NarInfo) Fields

func (NarInfo) Fields() []ent.Field

Fields of the NarInfo.

func (NarInfo) Indexes

func (NarInfo) Indexes() []ent.Index

Indexes of the NarInfo.

func (NarInfo) Mixin

func (NarInfo) Mixin() []ent.Mixin

Mixin of NarInfo.

type NarInfoNarFile

type NarInfoNarFile struct {
	ent.Schema
}

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) Edges

func (NarInfoNarFile) Edges() []ent.Edge

Edges of the NarInfoNarFile.

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

type NarInfoReference struct {
	ent.Schema
}

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

type NarInfoSignature struct {
	ent.Schema
}

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

type PinnedClosure struct {
	ent.Schema
}

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.

func (PinnedClosure) Mixin

func (PinnedClosure) Mixin() []ent.Mixin

Mixin of PinnedClosure.

Jump to

Keyboard shortcuts

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