interp

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: MIT Imports: 20 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadGoRegistry added in v1.9.0

func LoadGoRegistry(migrationsDir string) (*migrate.Registry, error)

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

func LoadRegistry(migrationsDir string) (*migrate.Registry, error)

LoadRegistry auto-detects the migration format in migrationsDir and loads all migrations into a *migrate.Registry. Both .go and .star files are supported in the same directory — legacy Go migrations coexist with newer Starlark ones. Duplicate migration names across formats are an error (the registry panics on duplicate Register calls, same as two .go files with the same name).

func LoadSchema added in v1.9.0

func LoadSchema(schemaDir string, verbose bool) (*types.Schema, error)

LoadSchema auto-detects the schema format in schemaDir and returns a *types.Schema. It looks for schema.star and schema.yaml. When both exist, schema.star takes precedence (the Starlark file is assumed to be the canonical source). If neither exists it returns an error.

func LoadStarlarkRegistry added in v1.9.0

func LoadStarlarkRegistry(migrationsDir string) (*migrate.Registry, error)

LoadStarlarkRegistry reads every *.star file in migrationsDir, evaluates them with the migration DSL builtins, and returns a populated *migrate.Registry.

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

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

Env returns a starlark.StringDict containing all builtin functions, suitable for injection as the predeclared environment of a Starlark thread.

Jump to

Keyboard shortcuts

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