seeder

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindSchemaFile

func FindSchemaFile() (string, error)

FindSchemaFile locates the schema.sql file

func GenerateCreatedAt

func GenerateCreatedAt() string

GenerateCreatedAt generates a random created_at timestamp within the last 90 days

func GenerateExampleValue

func GenerateExampleValue(column Column) string

GenerateExampleValue generates an example value for documentation/display purposes

func GenerateID

func GenerateID(index int) string

GenerateID generates a test seed ID

func GenerateValue

func GenerateValue(column Column) interface{}

GenerateValue generates a realistic value for a column based on its name and type

Types

type Column

type Column struct {
	Name      string
	Type      string
	Nullable  bool
	IsPrimary bool
}

type Index

type Index struct {
	Name    string
	Columns []string
}

type Seeder

type Seeder struct {
	// contains filtered or unexported fields
}

Seeder handles database seeding operations

func New

func New() (*Seeder, error)

New creates a new Seeder instance

func (*Seeder) Cleanup

func (s *Seeder) Cleanup(tableName string) error

Cleanup removes all test-seeded data from the given table

func (*Seeder) Close

func (s *Seeder) Close() error

Close closes the database connection

func (*Seeder) CountTestRecords

func (s *Seeder) CountTestRecords(tableName string) (int, error)

CountTestRecords counts the number of test-seeded records in a table

func (*Seeder) Seed

func (s *Seeder) Seed(table TableSchema, count int) error

Seed generates and inserts N rows of test data for the given table

type TableSchema

type TableSchema struct {
	Name       string
	Columns    []Column
	PrimaryKey string
	Indexes    []Index
}

func FindTable

func FindTable(tables []TableSchema, name string) *TableSchema

FindTable finds a table by name (case-insensitive)

func ParseSchema

func ParseSchema(schemaPath string) ([]TableSchema, error)

ParseSchema parses the schema.sql file and returns all table schemas

Jump to

Keyboard shortcuts

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