sqlc

package
v0.71.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClearStagedVersionParams

type ClearStagedVersionParams struct {
	NamespaceID string `json:"namespace_id"`
	SchemaID    string `json:"schema_id"`
}

type CreateNamespaceParams

type CreateNamespaceParams struct {
	ID                string      `json:"id"`
	Metadata          []byte      `json:"metadata"`
	ParentNamespaceID pgtype.Text `json:"parent_namespace_id"`
}

type CreateSchemaParams

type CreateSchemaParams struct {
	NamespaceID string `json:"namespace_id"`
	SchemaID    string `json:"schema_id"`
	Metadata    []byte `json:"metadata"`
}

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type GetBlobParams

type GetBlobParams struct {
	NamespaceID string `json:"namespace_id"`
	Sha256      string `json:"sha256"`
}

type GetBlobsByHashesParams

type GetBlobsByHashesParams struct {
	NamespaceID string   `json:"namespace_id"`
	Column2     []string `json:"column_2"`
}

type GetCrossNamespaceDependentsParams added in v0.71.0

type GetCrossNamespaceDependentsParams struct {
	DepNamespaceID string `json:"dep_namespace_id"`
	DepSchemaID    string `json:"dep_schema_id"`
	DepFilename    string `json:"dep_filename"`
	DepVersion     int64  `json:"dep_version"`
}

type GetCrossNamespaceDependentsRow added in v0.71.0

type GetCrossNamespaceDependentsRow struct {
	NamespaceID string `json:"namespace_id"`
	SchemaID    string `json:"schema_id"`
	Version     int64  `json:"version"`
}

type GetDependentsParams

type GetDependentsParams struct {
	NamespaceID string `json:"namespace_id"`
	DepSchemaID string `json:"dep_schema_id"`
}

type GetDependentsRow

type GetDependentsRow struct {
	SchemaID string `json:"schema_id"`
	Version  int64  `json:"version"`
}

type GetSchemaForUpdateParams

type GetSchemaForUpdateParams struct {
	NamespaceID string `json:"namespace_id"`
	SchemaID    string `json:"schema_id"`
}

type GetSchemaParams

type GetSchemaParams struct {
	NamespaceID string `json:"namespace_id"`
	SchemaID    string `json:"schema_id"`
}

type GetVersionDepsParams

type GetVersionDepsParams struct {
	NamespaceID string `json:"namespace_id"`
	SchemaID    string `json:"schema_id"`
	Version     int64  `json:"version"`
}

type GetVersionDepsRow added in v0.71.0

type GetVersionDepsRow struct {
	NamespaceID    string `json:"namespace_id"`
	SchemaID       string `json:"schema_id"`
	Version        int64  `json:"version"`
	DepNamespaceID string `json:"dep_namespace_id"`
	DepSchemaID    string `json:"dep_schema_id"`
	DepFilename    string `json:"dep_filename"`
	DepVersion     int64  `json:"dep_version"`
}

type GetVersionFilesParams

type GetVersionFilesParams struct {
	NamespaceID string `json:"namespace_id"`
	SchemaID    string `json:"schema_id"`
	Version     int64  `json:"version"`
}

type GetVersionParams

type GetVersionParams struct {
	NamespaceID string `json:"namespace_id"`
	SchemaID    string `json:"schema_id"`
	Version     int64  `json:"version"`
}

type InsertVersionDepParams

type InsertVersionDepParams struct {
	NamespaceID    string `json:"namespace_id"`
	SchemaID       string `json:"schema_id"`
	Version        int64  `json:"version"`
	DepNamespaceID string `json:"dep_namespace_id"`
	DepSchemaID    string `json:"dep_schema_id"`
	DepFilename    string `json:"dep_filename"`
	DepVersion     int64  `json:"dep_version"`
}

type InsertVersionFileParams

type InsertVersionFileParams struct {
	NamespaceID string `json:"namespace_id"`
	SchemaID    string `json:"schema_id"`
	Version     int64  `json:"version"`
	Filename    string `json:"filename"`
	BlobSha256  string `json:"blob_sha256"`
}

type InsertVersionParams

type InsertVersionParams struct {
	NamespaceID     string `json:"namespace_id"`
	SchemaID        string `json:"schema_id"`
	Version         int64  `json:"version"`
	Compiled        []byte `json:"compiled"`
	CompilerVersion string `json:"compiler_version"`
	CreatedBy       string `json:"created_by"`
	Metadata        []byte `json:"metadata"`
}

type ListNamespaceParentEventsPageParams added in v0.71.0

type ListNamespaceParentEventsPageParams struct {
	NamespaceID string `json:"namespace_id"`
	AfterID     int64  `json:"after_id"`
	PageLimit   int32  `json:"page_limit"`
}

type ListNamespaceParentEventsParams added in v0.71.0

type ListNamespaceParentEventsParams struct {
	NamespaceID string `json:"namespace_id"`
	Limit       int32  `json:"limit"`
}

type ListNamespacesPageParams

type ListNamespacesPageParams struct {
	ID    string `json:"id"`
	Limit int32  `json:"limit"`
}

type ListSchemasPageParams

type ListSchemasPageParams struct {
	NamespaceID string `json:"namespace_id"`
	SchemaID    string `json:"schema_id"`
	Limit       int32  `json:"limit"`
}

type ListVersionsParams

type ListVersionsParams struct {
	NamespaceID string `json:"namespace_id"`
	SchemaID    string `json:"schema_id"`
}

type LoadAllCurrentRow

type LoadAllCurrentRow struct {
	NamespaceID     string `json:"namespace_id"`
	SchemaID        string `json:"schema_id"`
	Version         int64  `json:"version"`
	Compiled        []byte `json:"compiled"`
	CompilerVersion string `json:"compiler_version"`
	Filename        string `json:"filename"`
	BlobSha256      string `json:"blob_sha256"`
}

type LoadNamespaceCurrentRow

type LoadNamespaceCurrentRow struct {
	NamespaceID     string `json:"namespace_id"`
	SchemaID        string `json:"schema_id"`
	Version         int64  `json:"version"`
	Compiled        []byte `json:"compiled"`
	CompilerVersion string `json:"compiler_version"`
	Filename        string `json:"filename"`
	BlobSha256      string `json:"blob_sha256"`
}

type LoadNamespaceProposedRow

type LoadNamespaceProposedRow struct {
	NamespaceID     string `json:"namespace_id"`
	SchemaID        string `json:"schema_id"`
	Version         int64  `json:"version"`
	Compiled        []byte `json:"compiled"`
	CompilerVersion string `json:"compiler_version"`
	Filename        string `json:"filename"`
	BlobSha256      string `json:"blob_sha256"`
}

type Namespace

type Namespace struct {
	ID                string             `json:"id"`
	CreatedAt         time.Time          `json:"created_at"`
	DeletedAt         pgtype.Timestamptz `json:"deleted_at"`
	Metadata          []byte             `json:"metadata"`
	ParentNamespaceID pgtype.Text        `json:"parent_namespace_id"`
}

type NamespaceParentEvent added in v0.71.0

type NamespaceParentEvent struct {
	ID               int64       `json:"id"`
	NamespaceID      string      `json:"namespace_id"`
	PreviousParentID pgtype.Text `json:"previous_parent_id"`
	NewParentID      pgtype.Text `json:"new_parent_id"`
	ActorID          string      `json:"actor_id"`
	OccurredAt       time.Time   `json:"occurred_at"`
}

type PromoteAllStagedRow

type PromoteAllStagedRow struct {
	SchemaID       string      `json:"schema_id"`
	CurrentVersion pgtype.Int8 `json:"current_version"`
}

type ProtoBlob

type ProtoBlob struct {
	NamespaceID    string    `json:"namespace_id"`
	Sha256         string    `json:"sha256"`
	OriginalSource []byte    `json:"original_source"`
	SizeBytes      int32     `json:"size_bytes"`
	CreatedAt      time.Time `json:"created_at"`
}

type PutBlobParams

type PutBlobParams struct {
	NamespaceID    string `json:"namespace_id"`
	Sha256         string `json:"sha256"`
	OriginalSource []byte `json:"original_source"`
	SizeBytes      int32  `json:"size_bytes"`
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) ClearNamespaceParent added in v0.71.0

func (q *Queries) ClearNamespaceParent(ctx context.Context, id string) (int64, error)

ClearNamespaceParent removes the parent linkage (resets to NULL, which is the implicit root). No cycle check needed.

func (*Queries) ClearStagedVersion

func (q *Queries) ClearStagedVersion(ctx context.Context, arg ClearStagedVersionParams) error

func (*Queries) CreateNamespace

func (q *Queries) CreateNamespace(ctx context.Context, arg CreateNamespaceParams) error

func (*Queries) CreateSchema

func (q *Queries) CreateSchema(ctx context.Context, arg CreateSchemaParams) error

func (*Queries) DiscardAllStaged

func (q *Queries) DiscardAllStaged(ctx context.Context, namespaceID string) error

func (*Queries) GetBlob

func (q *Queries) GetBlob(ctx context.Context, arg GetBlobParams) (ProtoBlob, error)

func (*Queries) GetBlobsByHashes

func (q *Queries) GetBlobsByHashes(ctx context.Context, arg GetBlobsByHashesParams) ([]ProtoBlob, error)

func (*Queries) GetCrossNamespaceDependents added in v0.71.0

func (q *Queries) GetCrossNamespaceDependents(ctx context.Context, arg GetCrossNamespaceDependentsParams) ([]GetCrossNamespaceDependentsRow, error)

GetCrossNamespaceDependents returns children that pin a specific (parent_namespace, parent_schema, parent_filename, parent_version) — "who depends on this parent file?". Used by phase 2b's Restore to rebuild compiled state and by phase 4's Rebase to find rebase-eligible children when a parent promotes.

func (*Queries) GetDependents

func (q *Queries) GetDependents(ctx context.Context, arg GetDependentsParams) ([]GetDependentsRow, error)

GetDependents returns same-namespace dependents of a schema. Cross- namespace dependents are returned by GetCrossNamespaceDependents.

func (*Queries) GetNamespace

func (q *Queries) GetNamespace(ctx context.Context, id string) (Namespace, error)

func (*Queries) GetSchema

func (q *Queries) GetSchema(ctx context.Context, arg GetSchemaParams) (Schema, error)

func (*Queries) GetSchemaForUpdate

func (q *Queries) GetSchemaForUpdate(ctx context.Context, arg GetSchemaForUpdateParams) (Schema, error)

func (*Queries) GetStagedSchemas

func (q *Queries) GetStagedSchemas(ctx context.Context, namespaceID string) ([]Schema, error)

func (*Queries) GetVersion

func (q *Queries) GetVersion(ctx context.Context, arg GetVersionParams) (SchemaVersion, error)

func (*Queries) GetVersionDeps

func (q *Queries) GetVersionDeps(ctx context.Context, arg GetVersionDepsParams) ([]GetVersionDepsRow, error)

func (*Queries) GetVersionFiles

func (q *Queries) GetVersionFiles(ctx context.Context, arg GetVersionFilesParams) ([]SchemaVersionFile, error)

func (*Queries) InsertVersion

func (q *Queries) InsertVersion(ctx context.Context, arg InsertVersionParams) error

func (*Queries) InsertVersionDep

func (q *Queries) InsertVersionDep(ctx context.Context, arg InsertVersionDepParams) error

func (*Queries) InsertVersionFile

func (q *Queries) InsertVersionFile(ctx context.Context, arg InsertVersionFileParams) error

func (*Queries) ListNamespaceParentEvents added in v0.71.0

func (q *Queries) ListNamespaceParentEvents(ctx context.Context, arg ListNamespaceParentEventsParams) ([]NamespaceParentEvent, error)

ListNamespaceParentEvents returns the re-parenting history for a namespace, newest first. Bounded by limit; for full history with pagination, use the keyset variant below.

func (*Queries) ListNamespaceParentEventsPage added in v0.71.0

func (q *Queries) ListNamespaceParentEventsPage(ctx context.Context, arg ListNamespaceParentEventsPageParams) ([]NamespaceParentEvent, error)

ListNamespaceParentEventsPage returns events with id strictly less than @after_id (or all events when @after_id is 0), newest first. Keyset pagination on the BIGSERIAL primary key — stable under concurrent inserts.

func (*Queries) ListNamespaces

func (q *Queries) ListNamespaces(ctx context.Context) ([]Namespace, error)

func (*Queries) ListNamespacesPage

func (q *Queries) ListNamespacesPage(ctx context.Context, arg ListNamespacesPageParams) ([]Namespace, error)

ListNamespacesPage returns at most $2 namespaces whose id is strictly greater than $1, ordered by id. Pass an empty string for $1 to start at the beginning. Keyset pagination: stable under concurrent inserts/deletes.

func (*Queries) ListSchemas

func (q *Queries) ListSchemas(ctx context.Context, namespaceID string) ([]Schema, error)

func (*Queries) ListSchemasPage

func (q *Queries) ListSchemasPage(ctx context.Context, arg ListSchemasPageParams) ([]Schema, error)

ListSchemasPage is the keyset-paginated variant. Returns at most $3 schemas in the namespace whose schema_id is strictly greater than $2, ordered by schema_id. Pass an empty string for $2 to start at the beginning.

func (*Queries) ListVersions

func (q *Queries) ListVersions(ctx context.Context, arg ListVersionsParams) ([]int64, error)

func (*Queries) LoadAllCurrent

func (q *Queries) LoadAllCurrent(ctx context.Context) ([]LoadAllCurrentRow, error)

func (*Queries) LoadNamespaceCurrent

func (q *Queries) LoadNamespaceCurrent(ctx context.Context, namespaceID string) ([]LoadNamespaceCurrentRow, error)

func (*Queries) LoadNamespaceProposed

func (q *Queries) LoadNamespaceProposed(ctx context.Context, namespaceID string) ([]LoadNamespaceProposedRow, error)

func (*Queries) PromoteAllStaged

func (q *Queries) PromoteAllStaged(ctx context.Context, namespaceID string) ([]PromoteAllStagedRow, error)

func (*Queries) PutBlob

func (q *Queries) PutBlob(ctx context.Context, arg PutBlobParams) error

func (*Queries) RecordNamespaceParentEvent added in v0.71.0

func (q *Queries) RecordNamespaceParentEvent(ctx context.Context, arg RecordNamespaceParentEventParams) error

Append-only audit log for namespace re-parenting events. See docs/design/namespace-hierarchy.md decision D9.

Phase 1 ships the schema and queries; callers (the SetNamespaceParent RPC) wire them up in phase 3.

func (*Queries) SetCurrentVersion

func (q *Queries) SetCurrentVersion(ctx context.Context, arg SetCurrentVersionParams) error

func (*Queries) SetNamespaceParent added in v0.71.0

func (q *Queries) SetNamespaceParent(ctx context.Context, arg SetNamespaceParentParams) (int64, error)

SetNamespaceParent atomically sets a namespace's parent with cycle prevention via a recursive CTE. Returns the number of affected rows: 0 means either the namespace doesn't exist, the parent doesn't exist, or setting this parent would create a cycle (including self-reference). Callers should treat 0 as a logical failure and report accordingly.

The depth bound (64) is a safety guard: PostgreSQL does not auto-detect cycles in recursive CTEs and would loop indefinitely on a pre-existing cycle. 64 is far beyond any reasonable hierarchy depth.

func (*Queries) SetStagedVersion

func (q *Queries) SetStagedVersion(ctx context.Context, arg SetStagedVersionParams) error

func (*Queries) SoftDeleteNamespace

func (q *Queries) SoftDeleteNamespace(ctx context.Context, id string) error

func (*Queries) SoftDeleteSchema

func (q *Queries) SoftDeleteSchema(ctx context.Context, arg SoftDeleteSchemaParams) error

func (*Queries) SoftDeleteVersion

func (q *Queries) SoftDeleteVersion(ctx context.Context, arg SoftDeleteVersionParams) error

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type RecordNamespaceParentEventParams added in v0.71.0

type RecordNamespaceParentEventParams struct {
	NamespaceID      string      `json:"namespace_id"`
	PreviousParentID pgtype.Text `json:"previous_parent_id"`
	NewParentID      pgtype.Text `json:"new_parent_id"`
	ActorID          string      `json:"actor_id"`
}

type Schema

type Schema struct {
	NamespaceID    string             `json:"namespace_id"`
	SchemaID       string             `json:"schema_id"`
	CurrentVersion pgtype.Int8        `json:"current_version"`
	StagedVersion  pgtype.Int8        `json:"staged_version"`
	CreatedAt      time.Time          `json:"created_at"`
	DeletedAt      pgtype.Timestamptz `json:"deleted_at"`
	Metadata       []byte             `json:"metadata"`
}

type SchemaVersion

type SchemaVersion struct {
	NamespaceID     string             `json:"namespace_id"`
	SchemaID        string             `json:"schema_id"`
	Version         int64              `json:"version"`
	Compiled        []byte             `json:"compiled"`
	CompilerVersion string             `json:"compiler_version"`
	CreatedAt       time.Time          `json:"created_at"`
	CreatedBy       string             `json:"created_by"`
	DeletedAt       pgtype.Timestamptz `json:"deleted_at"`
	Metadata        []byte             `json:"metadata"`
}

type SchemaVersionDep

type SchemaVersionDep struct {
	NamespaceID    string `json:"namespace_id"`
	SchemaID       string `json:"schema_id"`
	Version        int64  `json:"version"`
	DepSchemaID    string `json:"dep_schema_id"`
	DepFilename    string `json:"dep_filename"`
	DepVersion     int64  `json:"dep_version"`
	DepNamespaceID string `json:"dep_namespace_id"`
}

type SchemaVersionFile

type SchemaVersionFile struct {
	NamespaceID string `json:"namespace_id"`
	SchemaID    string `json:"schema_id"`
	Version     int64  `json:"version"`
	Filename    string `json:"filename"`
	BlobSha256  string `json:"blob_sha256"`
}

type SetCurrentVersionParams

type SetCurrentVersionParams struct {
	NamespaceID    string      `json:"namespace_id"`
	SchemaID       string      `json:"schema_id"`
	CurrentVersion pgtype.Int8 `json:"current_version"`
}

type SetNamespaceParentParams added in v0.71.0

type SetNamespaceParentParams struct {
	NewParentID string `json:"new_parent_id"`
	NamespaceID string `json:"namespace_id"`
}

type SetStagedVersionParams

type SetStagedVersionParams struct {
	NamespaceID   string      `json:"namespace_id"`
	SchemaID      string      `json:"schema_id"`
	StagedVersion pgtype.Int8 `json:"staged_version"`
}

type SoftDeleteSchemaParams

type SoftDeleteSchemaParams struct {
	NamespaceID string `json:"namespace_id"`
	SchemaID    string `json:"schema_id"`
}

type SoftDeleteVersionParams

type SoftDeleteVersionParams struct {
	NamespaceID string `json:"namespace_id"`
	SchemaID    string `json:"schema_id"`
	Version     int64  `json:"version"`
}

Jump to

Keyboard shortcuts

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