Documentation
¶
Overview ¶
Package migrationartifact owns atomic, immutable migration artifact files.
Index ¶
- Constants
- Variables
- func AdoptionEnd(files []File, applied int, blockingStep func(File) string, ...) (int, error)
- func LatestManifest(directory string) (schema.Manifest, bool, error)
- type File
- func Create(directory, name string, artifact migration.Artifact, now time.Time) (File, error)
- func ReadAll(directory string) ([]File, error)
- func RequireCurrentHistory(directory string, executable schema.Manifest) ([]File, error)
- func RequireCurrentHistoryForPlanner(directory string, executable schema.Manifest, plannerName string) ([]File, error)
Constants ¶
const Extension = ".ridu.json"
Extension distinguishes Ridu artifacts from arbitrary JSON.
Variables ¶
var ( // ErrSchemaCurrent reports that a new migration would record nothing: // the schema is the one the latest migration records. ErrSchemaCurrent = errors.New("schema is current") // ErrOnlyAdminChanges reports that the schema differs from the latest // migration only in admin settings, which history ignores. ErrOnlyAdminChanges = fmt.Errorf("%w; only admin settings changed, so no migration is needed", ErrSchemaCurrent) )
Functions ¶
func AdoptionEnd ¶ added in v0.9.0
func AdoptionEnd(files []File, applied int, blockingStep func(File) string, matches func(index int) (bool, error)) (int, error)
AdoptionEnd decides how much of a pending history a baseline may record as applied without running it, on a database that schema sync already brought forward. It returns the history length after adoption: the newest artifact whose resulting schema the database has, provided no artifact up to it has a step schema sync never runs. Later artifacts stay pending for ridu migrate up.
matches reports whether the database's physical schema equals the schema after files[index]; blockingStep names a step that only a migration runner performs, or returns "" when every step is physical.
Types ¶
type File ¶
File contains one parsed immutable migration and its filesystem identity.
func Create ¶
Create atomically creates one migration artifact and never overwrites an existing filename.
func RequireCurrentHistory ¶
RequireCurrentHistory proves that a deployable executable manifest is the exact head of a non-empty, immutable artifact history. An empty history is a valid input only to migration creation; release checks and database commands must fail closed until the initial artifact has been created and committed.
func RequireCurrentHistoryForPlanner ¶
func RequireCurrentHistoryForPlanner(directory string, executable schema.Manifest, plannerName string) ([]File, error)
RequireCurrentHistoryForPlanner additionally proves that every immutable artifact belongs to the planner family selected by the project database. Adapter runners retain ownership of planner-version and exact-plan checks.