Documentation
¶
Overview ¶
Package interp loads morphic migration .go files into an in-process *migrate.Registry using the yaegi interpreter, removing the need to compile the migrations module with the Go toolchain.
schema_builtins.go defines Starlark builtins for the schema DSL (.star schema files). These builtins let users declare databases, tables, defaults, type mappings, and includes — collecting everything into a *types.Schema.
schema_loader.go auto-detects whether a schema directory contains a .star or .yaml schema file and loads it into a *types.Schema.
starlark_builtins.go defines the Starlark builtin functions that migration .star scripts call. These functions convert Starlark values into migrate.* operation structs.
Index ¶
- func LoadGoRegistry(migrationsDir string) (*migrate.Registry, error)
- func LoadRegistry(migrationsDir string) (*migrate.Registry, error)
- func LoadSchema(schemaDir string, verbose bool) (*types.Schema, error)
- func LoadStarlarkRegistry(migrationsDir string) (*migrate.Registry, error)
- type SchemaDSLBuiltins
- type StarlarkBuiltins
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadGoRegistry ¶ added in v1.9.0
LoadGoRegistry reads every *.go file in migrationsDir (except main.go), interprets them with yaegi, and returns a freshly-populated *migrate.Registry.
Each migration file's init() calls migrate.Register, which is intercepted here and routed into the returned registry rather than the package-level global. This lets the function be called multiple times in a single process without duplicate-registration panics.
func LoadRegistry ¶
LoadRegistry auto-detects the migration format in migrationsDir and loads all migrations into a *migrate.Registry. If both .go and .star files exist, it returns an error (mixed formats are not supported).
func LoadSchema ¶ added in v1.9.0
LoadSchema auto-detects the schema format in schemaDir and returns a *types.Schema. It looks for schema.star and schema.yaml. If both exist it returns an error; if neither exists it also returns an error.
Types ¶
type SchemaDSLBuiltins ¶ added in v1.9.0
type SchemaDSLBuiltins struct {
// contains filtered or unexported fields
}
SchemaDSLBuiltins holds the Starlark builtins for schema .star files and accumulates the resulting types.Schema as each builtin is called.
func NewSchemaDSLBuiltins ¶ added in v1.9.0
func NewSchemaDSLBuiltins() *SchemaDSLBuiltins
NewSchemaDSLBuiltins creates a new SchemaDSLBuiltins with an empty schema.
func (*SchemaDSLBuiltins) Collected ¶ added in v1.9.0
func (s *SchemaDSLBuiltins) Collected() *types.Schema
Collected returns the accumulated schema after script execution.
func (*SchemaDSLBuiltins) Env ¶ added in v1.9.0
func (s *SchemaDSLBuiltins) Env() starlark.StringDict
Env returns a starlark.StringDict containing all schema DSL builtins plus the shared field/index/fk leaf builtins from StarlarkBuiltins.
type StarlarkBuiltins ¶ added in v1.9.0
type StarlarkBuiltins struct {
// contains filtered or unexported fields
}
StarlarkBuiltins holds all builtin functions injected into .star scripts and collects the resulting Migration after script execution.
func NewStarlarkBuiltins ¶ added in v1.9.0
func NewStarlarkBuiltins() *StarlarkBuiltins
NewStarlarkBuiltins creates a new StarlarkBuiltins instance.
func (*StarlarkBuiltins) Collected ¶ added in v1.9.0
func (b *StarlarkBuiltins) Collected() *migrate.Migration
Collected returns the migration that was collected by the migration() builtin, or nil if migration() was never called.
func (*StarlarkBuiltins) Env ¶ added in v1.9.0
func (b *StarlarkBuiltins) Env() starlark.StringDict
Env returns a starlark.StringDict containing all builtin functions, suitable for injection as the predeclared environment of a Starlark thread.