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

enableversions

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package enableversions plans and checks a collection or global that starts keeping versions while it may already store documents. Each store adapter executes the plan; this package owns the choices and what they mean.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert

func Convert(resource schema.Collection, document store.Document, existing migration.ExistingDocuments) store.Document

Convert returns document as a resource that keeps versions stores it after existing applies: published with a live head, or an unpublished draft. Its revision starts at 1 unless the document already has one.

func Describe

func Describe(resource schema.Collection) string

Describe names a resource for messages, such as collection "posts".

func NotEmptyError

func NotEmptyError(resource schema.Collection, documents int64) error

NotEmptyError rejects a require-empty choice for a resource that stores documents.

func StoredDocumentsError

func StoredDocumentsError(resource schema.Collection, documents int64) error

StoredDocumentsError rejects development schema sync that would enable versions on a resource that stores documents.

func Validate

func Validate(resource schema.Collection, existing migration.ExistingDocuments) error

Validate checks that existing is a choice resource can take.

Types

type Choices

Choices maps each resource that starts keeping versions, by its after stable ID, to what becomes of the documents it already stores.

func Recorded

func Recorded(artifact migration.Artifact) (Choices, error)

Recorded returns the choices an artifact's enable-versions steps record.

type Report

type Report struct {
	Resource  schema.Collection
	Documents int64
}

Report is how many documents, trashed ones included, a resource that starts keeping versions already stores.

type Step

type Step struct {
	Resource schema.Collection
	Existing migration.ExistingDocuments
}

Step is one resource that starts keeping versions, with what becomes of the documents it already stores.

func Plan

func Plan(before, after schema.Snapshot, renames map[schema.StableID]schema.StableID, choices Choices) ([]Step, error)

Plan returns a step for each resource that starts keeping versions between before and after, in migration.VersionsEnabled order. Every such resource needs a choice, and only those resources may have one.

func (Step) Name

func (step Step) Name() string

Name labels the step in the artifact.

func (Step) Payload

func (step Step) Payload() migration.EnableVersionsPayload

Payload is the step's immutable artifact record.

func (Step) Risk

func (step Step) Risk() migration.Risk

Risk explains to a reviewer what the step does to stored documents.

Jump to

Keyboard shortcuts

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