db

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DataMigrationTable                   = "goose_db_data_version"
	SchemaMigrationTable                 = "goose_db_schema_version"
	SharedSchema                         = "public"
	SchemaMigration      MigrationType   = "schema"
	DataMigration        MigrationType   = "data"
	SharedTarget         MigrationTarget = "shared"
	TenantTarget         MigrationTarget = "tenant"
	AllTarget            MigrationTarget = "all"
)
View Source
const DBLogDomain = "db"

Variables

View Source
var (
	ErrStartingDBCon            = errors.New("error starting db connection")
	ErrDBResolver               = errors.New("error starting db resolver")
	ErrLoadingDsnFromDBConfig   = errors.New("error loading dsn from db config")
	ErrLoadingReplicaDialectors = errors.New("error loading replica dialectors")
)
View Source
var (
	ErrEmptyManagementAccessData = errors.New("management access data cannot be empty")
	ErrManagementAccessDataType  = errors.New("management access data must be a literal string")
	ErrNilManagementAccessData   = errors.New("management access data cannot be nil")
	ErrEmptyLocalityID           = errors.New("locality ID cannot be empty")
	ErrEmptyCommonName           = errors.New("common name cannot be empty")
	ErrEmptySupportedRegions     = errors.New("supported regions cannot be empty")
	ErrEmptyRegionName           = errors.New("region name cannot be empty")
	ErrEmptyRegionTechName       = errors.New("region technical name cannot be empty")
)
View Source
var ErrCommandUnsuported = errors.New("command not supported")
View Source
var ErrUnsupportedMigration = errors.New("unsupported migration")

Functions

func QuoteSchema

func QuoteSchema(schema string) string

func StartDB

func StartDB(
	ctx context.Context,
	cfg *config.Config,
) (*multitenancy.DB, error)

StartDB starts DB connection and runs migrations

func StartDBConnection

func StartDBConnection(
	ctx context.Context,
	conf config.Database,
	replicas []config.Database,
) (*multitenancy.DB, error)

StartDBConnection opens DB connection using data from `config.DB`.

func StartDBConnectionPlugins

func StartDBConnectionPlugins(
	ctx context.Context,
	conf config.Database,
	replicas []config.Database,
	plugins map[string]gorm.Plugin,
) (*multitenancy.DB, error)

StartDBConnectionPlugins opens DB connection using data from `config.DB` and plugins that are passed in a form of map because GORM config stores them this way. It is an extension of `StartDBConnection` functionality.

Types

type Migration

type Migration struct {
	Downgrade bool
	Type      MigrationType
	Target    MigrationTarget
}

type MigrationTarget

type MigrationTarget string

type MigrationType

type MigrationType string

type Migrator

type Migrator interface {
	MigrateTenantToLatest(ctx context.Context, tenant *model.Tenant) error
	MigrateToLatest(ctx context.Context, migration Migration) error
	MigrateTo(ctx context.Context, migration Migration, version int64) error
}

func NewMigrator

func NewMigrator(r repo.Repo, cfg *config.Config) (Migrator, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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