db

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDemoCmd

func GetDemoCmd(ctx *appContext.Context) *cobra.Command

func GetDemoRunFn

func GetDemoRunFn(ctx *appContext.Context) func(*cobra.Command, []string) error

func GetInitCmd

func GetInitCmd(ctx *appContext.Context) *cobra.Command

func GetInitRunFn

func GetInitRunFn(ctx *appContext.Context) func(*cobra.Command, []string) error

func GetMigrateCmd

func GetMigrateCmd(ctx *appContext.Context) *cobra.Command

Types

type CreateDemoDBFn

type CreateDemoDBFn func(ctx *appContext.Context) (*gorm.DB, error)

CreateDemoDBFn is a function type for creating database connection (used for testing)

var NewDemoDB CreateDemoDBFn = func(ctx *appContext.Context) (*gorm.DB, error) {
	return database.CreateDB(ctx)
}

NewDemoDB is the function used to create database connection (can be replaced in tests)

type CreateInitDBFn

type CreateInitDBFn func(ctx *appContext.Context) (*gorm.DB, error)

CreateInitDBFn is a function type for creating database connection (used for testing)

var NewInitDB CreateInitDBFn = func(ctx *appContext.Context) (*gorm.DB, error) {
	return database.CreateDB(ctx)
}

NewInitDB is the function used to create database connection (can be replaced in tests)

type Migrator

type Migrator interface {
	Up() error
	Down() error
	Steps(n int) error
	Version() (version uint, dirty bool, err error)
}

Migrator defines the interface for database migrations

type MigratorFactory

type MigratorFactory func(ctx *appContext.Context) (Migrator, error)

MigratorFactory creates a Migrator instance

var NewMigrator MigratorFactory = createMigrator

NewMigrator is the factory function to create a Migrator (injectable for testing)

Jump to

Keyboard shortcuts

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