infra

package
v0.0.0-...-080604a Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultSource = "default_source"
)

Variables

View Source
var DBSourceNotFoundError = errors.New("database source not found")

Functions

func AddDBSource

func AddDBSource(name string, source *gorm.DB)

AddDBSource adds a new source to the sources map If the source already exists, it will be overwritten

func GetDBSource

func GetDBSource(name string) (*gorm.DB, error)

GetDBSource returns a source from the sources map If the source does not exist, it will return an error

func InitializeMigrator

func InitializeMigrator(driver database.Driver, conf MigratorConfig) error

InitializeMigrator initializes the migrator

func InitializeSources

func InitializeSources(sourcesMap map[string]*gorm.DB)

InitializeSources initializes the sources map If the map is nil, it will create a new one

Types

type MigratorConfig

type MigratorConfig struct {
	MigrationsFolder string `inject:"property:db.migrator.folder;default:resources/migrations"`
	DriverName       string `inject:"property:db.driver;default:postgres"`
	Enabled          bool   `inject:"property:db.migrator.enabled;default:true"`
}

MigratorConfig is the configuration for the migrator It is used to inject the configuration from the config file The default values are used if the configuration is not found The default values are:

MigrationsFolder: resources/migrations (relative to the project root)

DriverName: postgres

Enabled: true

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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