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
- func Group() *migrate.Group
- func NewOrchestrator(drv any) (*migrate.Orchestrator, error)
- func NewOrchestratorFromGrove(gdb *grove.DB) (*migrate.Orchestrator, func() error, error)
- func OpenOrchestrator(ctx context.Context, dsn string) (*migrate.Orchestrator, func() error, error)
- func OpenOrchestratorWith(ctx context.Context, dsn string, gdb *grove.DB) (*migrate.Orchestrator, func() error, error)
- func ScopeAwareTenantPolicy(table string) []string
Constants ¶
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 ¶
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
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 ¶
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 ¶
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.
Source Files
¶
- 0001_outbox.go
- 0002_projection_state.go
- 0003_site_asset_tag.go
- 0004_rls_policies.go
- 0005_timescale.go
- 0006_pgvector.go
- 0007_crdt_updates.go
- 0008_crdt_docs.go
- 0009_link.go
- 0010_live_subscriptions.go
- 0011_postgis.go
- 0012_scope.go
- 0013_crdt_scope.go
- 0014_blob.go
- 0015_blob_cas_created_at.go
- 0016_fs_node.go
- 0017_fs_node_mount.go
- 0018_fs_permission.go
- 0019_fs_share.go
- 0020_fs_bookmark.go
- 0021_blob_source.go
- 0022_digest_node.go
- 0023_digest_tokens.go
- 0024_digest_content_hash_idx.go
- 0025_embeddings_meta_gin.go
- module.go
- runner.go