Documentation ¶
Overview ¶
Package database implements common functionality for database with gorm.
Index ¶
- Variables
- type ConnectionURI
- type Database
- func (config *Database) AddMigration(m ...*gormigrate.Migration)
- func (config *Database) AddMigrationTestdata(m ...*gormigrate.Migration)
- func (config *Database) Migrate() error
- func (config *Database) MigrateTestdata() error
- func (config *Database) ReMigrate(id string) error
- func (config *Database) ReRun() error
- func (config *Database) Run() error
- func (config *Database) Status() error
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.2.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.2.0
func (uri *ConnectionURI) String() string
type Database ¶ added in v1.2.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.2.0
func (config *Database) AddMigration(m ...*gormigrate.Migration)
AddMigration add to database config migration step
func (*Database) AddMigrationTestdata ¶ added in v1.2.0
func (config *Database) AddMigrationTestdata(m ...*gormigrate.Migration)
AddMigrationTestdata add to database config migration step of testdata
func (*Database) MigrateTestdata ¶ added in v1.2.0
MigrateTestdata run migration and testdata migration
func (*Database) ReMigrate ¶ added in v1.2.0
ReMigrate Rollback und run every migration step again till id
Click to show internal directories.
Click to hide internal directories.