database

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package database implements common functionality for database with gorm.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotConnected - database is not connected
	ErrNotConnected = errors.New("database is not connected")
	// ErrNothingToMigrate if nothing has to be migrated
	ErrNothingToMigrate = errors.New("there is nothing to migrate")
)

Functions

This section is empty.

Types

type ConnectionURI added in v1.3.0

type ConnectionURI struct {
	URI          string `config:"string"`
	Hostname     string `config:"hostname"`
	Username     string `config:"username"`
	Password     string `config:"password"`
	DatabaseName string `config:"dbname"`
	ExtraOptions string `config:"extra_options"`
}

func (*ConnectionURI) String added in v1.3.0

func (uri *ConnectionURI) String() string

type Database added in v1.3.0

type Database struct {
	DB         *gorm.DB        `config:"-" toml:"-"`
	Connection ConnectionURI   `config:"connection" toml:"connection"`
	Debug      bool            `config:"debug" toml:"debug"`
	Testdata   bool            `config:"testdata" toml:"testdata"`
	LogLevel   logger.LogLevel `config:"log_level" toml:"log_level"`
	// contains filtered or unexported fields
}

Database struct to read from config

func (*Database) AddMigration added in v1.3.0

func (config *Database) AddMigration(m ...*gormigrate.Migration)

AddMigration add to database config migration step

func (*Database) AddMigrationTestdata added in v1.3.0

func (config *Database) AddMigrationTestdata(m ...*gormigrate.Migration)

AddMigrationTestdata add to database config migration step of testdata

func (*Database) Migrate added in v1.3.0

func (config *Database) Migrate() error

Migrate run migration

func (*Database) MigrateTestdata added in v1.3.0

func (config *Database) MigrateTestdata() error

MigrateTestdata run migration and testdata migration

func (*Database) ReMigrate added in v1.3.0

func (config *Database) ReMigrate(id string) error

ReMigrate Rollback und run every migration step again till id

func (*Database) ReRun added in v1.3.0

func (config *Database) ReRun() error

ReRun database config - connect and re migration

func (*Database) Run added in v1.3.0

func (config *Database) Run() error

Run database config - connect and migrate

func (*Database) Status added in v1.3.0

func (config *Database) Status() error

Status get status - is database pingable

Jump to

Keyboard shortcuts

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