Documentation
¶
Index ¶
- Variables
- func Module(opts ...di.Node) di.Node
- func NewDialector(config Config) gorm.Dialector
- func NewGooseZapLogger(logger *zap.Logger) goose.Logger
- func NewGormDB(dialecter gorm.Dialector) (*gorm.DB, error)
- func NewPostgresDialector(config Config) gorm.Dialector
- func ParseDialect(d string) string
- func RunMigrations() di.Node
- func UseMigrations(migrationsDirFS *embed.FS, paths ...string) di.Node
- func UseOtel() di.Node
- type Config
- type ContextFn
- type GormChecker
- type GormOtel
- type LogConfig
- type Logger
- func (l Logger) Error(ctx context.Context, str string, args ...any)
- func (l Logger) Info(ctx context.Context, str string, args ...any)
- func (l Logger) LogMode(level gormlogger.LogLevel) gormlogger.Interface
- func (l Logger) ParamsFilter(ctx context.Context, sql string, params ...any) (string, []any)
- func (l Logger) SetAsDefault()
- func (l Logger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)
- func (l Logger) Warn(ctx context.Context, str string, args ...any)
- type Migration
- type Option
- type TraceConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrNoMigrationsSource = errors.New("database: no migration source provided (did you forget to call UseMigrations?)")
)
Functions ¶
func NewDialector ¶ added in v1.12.0
func NewGooseZapLogger ¶ added in v1.12.0
NewGooseZapLogger adapts zap.Logger to goose.Logger.
func NewPostgresDialector ¶
NewPostgresDialector is kept for backward compatibility.
func ParseDialect ¶ added in v1.12.0
func RunMigrations ¶ added in v1.5.0
RunMigrations runs goose migrations using the source registered by UseMigrations.
func UseMigrations ¶
UseMigrations registers migration files in the DI container.
Types ¶
type Config ¶
type Config struct {
Dialect string `mapstructure:"dialect"`
Migrate bool `mapstructure:"migrate"`
Datasource string `mapstructure:"datasource"`
Log LogConfig `mapstructure:"log"`
Trace TraceConfig `mapstructure:"trace"`
}
type GormChecker ¶ added in v1.12.0
func NewGormChecker ¶ added in v1.12.0
func NewGormChecker(cfg Config, db *gorm.DB) *GormChecker
func (*GormChecker) Check ¶ added in v1.12.0
func (g *GormChecker) Check() error
type LogConfig ¶ added in v1.4.0
type LogConfig struct {
Enabled *bool `mapstructure:"enabled"`
LogLevel string `mapstructure:"level" default:"warn"`
SlowThreshold time.Duration `mapstructure:"slow_threshold" default:"100ms"`
SkipCallerLookup bool `mapstructure:"skip_caller_lookup" default:"false"`
IgnoreRecordNotFoundError bool `mapstructure:"ignore_record_not_found_error" default:"false"`
ParameterizedQueries bool `mapstructure:"parameterized_queries" default:"true"`
}
type Logger ¶
type Logger struct {
ZapLogger *zap.Logger
LogLevel gormlogger.LogLevel
SlowThreshold time.Duration
SkipCallerLookup bool
IgnoreRecordNotFoundError bool
Context ContextFn
ParameterizedQueries bool
}
func (Logger) LogMode ¶
func (l Logger) LogMode(level gormlogger.LogLevel) gormlogger.Interface
func (Logger) ParamsFilter ¶
func (Logger) SetAsDefault ¶
func (l Logger) SetAsDefault()
type Migration ¶ added in v1.12.0
func NewMigration ¶ added in v1.12.0
type TraceConfig ¶ added in v1.4.0
type TraceConfig struct {
Enabled *bool `mapstructure:"enabled"`
DBName string `mapstructure:"db_name"`
Attributes map[string]string `mapstructure:"attributes"`
WithoutQueryVariables bool `mapstructure:"without_query_variables" default:"true"`
WithoutMetrics bool `mapstructure:"without_metrics" default:"false"`
IncludeDryRunSpans bool `mapstructure:"include_dry_run_spans" default:"false"`
}
Click to show internal directories.
Click to hide internal directories.