seed

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package seed implements the DB seeding fixtures system for nSelf projects. Seeds are SQL files organized by environment and fixture type, with support for idempotent and destructive headers, dependency ordering, and verification.

Index

Constants

View Source
const (
	HeaderIdempotent  = "-- +seed:idempotent"
	HeaderDestructive = "-- +seed:destructive"
	HeaderDependsOn   = "-- +seed:depends-on "
)

SeedHeader directives parsed from SQL comments.

Variables

This section is empty.

Functions

func FixtureDir

func FixtureDir(projectDir, fixture string) string

FixtureDir returns the directory for a specific fixture.

func ListFixtures

func ListFixtures(projectDir string) ([]string, error)

ListFixtures returns available fixture names.

func SeedDir

func SeedDir(projectDir string) string

SeedDir returns the base seeds directory for a project.

Types

type GraphNode

type GraphNode struct {
	Name      string
	Env       string
	DependsOn []string
}

GraphNode represents a seed file in the dependency graph.

func DependencyGraph

func DependencyGraph(projectDir string) ([]GraphNode, error)

DependencyGraph returns the seed files with their dependency relationships as a printable adjacency list.

type SeedFile

type SeedFile struct {
	Path        string
	Name        string
	Env         string // _common, dev, staging, prod, or fixture name
	Idempotent  bool
	Destructive bool
	DependsOn   []string
}

SeedFile describes a single seed SQL file with parsed metadata.

func CollectForRun

func CollectForRun(projectDir, env, fixture string) ([]SeedFile, error)

CollectForRun returns the ordered list of seed files to execute for a given environment and optional fixture. Order: _common first, then env-specific, then fixture if specified.

func ListSeeds

func ListSeeds(projectDir string) ([]SeedFile, error)

ListSeeds returns all available seed files grouped by category.

func ParseHeader

func ParseHeader(path string) (SeedFile, error)

ParseHeader reads a seed file and extracts its metadata headers.

Jump to

Keyboard shortcuts

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