migrations

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package migrations is fabriq's DDL authority: grove Go-code migrations for every fabriq-owned table. The registry never generates DDL; the registry-conformance integration test keeps the two in sync.

Run them with `fabriq migrate up|down|status` (which wraps grove's orchestrator under its advisory migration lock) — never at app startup. Expand/contract discipline is documented in docs/MIGRATIONS.md.

Index

Constants

View Source
const GroupName = "fabriq"

GroupName identifies fabriq's migration group; host applications that embed fabriq alongside their own grove migration groups can depend on it (migrate.DependsOn(migrations.GroupName)).

Variables

This section is empty.

Functions

func Group

func Group() *migrate.Group

Group returns fabriq's migration group with all migrations registered, in version order.

func NewOrchestrator

func NewOrchestrator(drv any) (*migrate.Orchestrator, error)

NewOrchestrator builds a grove migration orchestrator for the given driver (a *pgdriver.PgDB). The orchestrator acquires grove's migration lock on a dedicated connection, so concurrent `fabriq migrate` runs are safe.

func NewOrchestratorFromGrove added in v0.0.3

func NewOrchestratorFromGrove(gdb *grove.DB) (*migrate.Orchestrator, func() error, error)

NewOrchestratorFromGrove builds an orchestrator on an already-open grove.DB borrowed from a host DI container — the migration counterpart to the forge extension's grove fallback (mirrors how xraph/authsome shares the host grove). The grove MUST be pg-backed. The returned close func is a no-op: the host owns the connection lifecycle, so migrations must not tear it down.

func OpenOrchestrator

func OpenOrchestrator(ctx context.Context, dsn string) (*migrate.Orchestrator, func() error, error)

OpenOrchestrator dials Postgres and returns a ready orchestrator plus a close function. It exists so the CLI (and worker bootstrap) can run migrations without importing grove drivers directly — driver imports stay fenced to adapters/, fabriqtest/ and this package.

func OpenOrchestratorWith added in v0.0.3

func OpenOrchestratorWith(ctx context.Context, dsn string, gdb *grove.DB) (*migrate.Orchestrator, func() error, error)

OpenOrchestratorWith returns a migration orchestrator, preferring an explicit DSN (dialing a fresh connection it owns and closes) and otherwise borrowing the given grove.DB. It errors when neither is available, so a misconfigured caller gets a clear message instead of an "empty dsn" dial failure.

func ScopeAwareTenantPolicy

func ScopeAwareTenantPolicy(table string) []string

ScopeAwareTenantPolicy returns the SQL to (re)create the tenant_isolation policy with the soft secondary-scope predicate for a table that has a nullable scope_id column. Tenant stays the hard boundary; scope is soft: an unscoped read (app.scope_id=”) sees all rows in the tenant; a scoped read sees its scope plus shared (NULL-scope) rows. Consumers (kgkit/twinos) reuse this for their own entity tables that adopt scope_id.

Types

This section is empty.

Jump to

Keyboard shortcuts

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