← Versioned state

State.Migration

luastra/state

State.Migration is an exported, statically checked data contract of luastra/state. Its exact declaration documents the fields or alternatives accepted at the module boundary and is erased after Luau analysis.

Before you use it

Add luastra/state to this module's dependencies in luastra.json, then import it with require("luastra/state"). No capability is required for encoding, decoding, or migration. Persistence additionally needs luastra/host plus storage.get and storage.set.

How it fits

The type describes string fields, migration functions, or tagged decode/migration results.

When to use it

Use State.Migration when annotating values that cross the public luastra/state boundary or when exporting helpers built on that module. The type documents the exact checked shape and prevents unrelated tables from being substituted accidentally.

Fields or definition

ParameterType / valuesDescription
definition(fields: Fields) -> FieldsExact alias, union, or callable contract represented by State.Migration.

What happens next

A checked snapshot or result annotation.

Failures and fixes

Malformed data, wrong versions, missing migration steps, excessive size, or non-string fields remain explicit failure branches. Do not silently replace corrupt security- or domain-sensitive values with defaults.

Availability

Public-source alpha API in 0.5.0-alpha; persistence support is host-dependent.

Exact declaration

export type Migration = (fields: Fields) -> Fields

Complete inventory

View all pages in Versioned state
← Previous: State.MigrationResultNext: State.encode →