Documentation ¶
Overview ¶
Package database contains utilities for interacting with databases.
Index ¶
- Variables
- func FromInterval(interval pgtype.Interval) time.Duration
- func FromTextArray(ta pgtype.TextArray) []string
- func Migrate(action func(*migrate.Migrate) error, source *MigrationSource, db *sql.DB) error
- func MigrateDown(s *MigrationSource, db *sql.DB) error
- func MigrateUp(s *MigrationSource, db *sql.DB) error
- func ToInterval(dur time.Duration) pgtype.Interval
- func ToTextArray(arr []string) pgtype.TextArray
- func WithinTransaction(ctx context.Context, db *sql.DB, ...) error
- type MigrationSource
Constants ¶
This section is empty.
Variables ¶
var ErrNotADirectory = errors.New("invalid migration directory")
ErrNotADirectory is returned if attempting to migrate without a valid directory.
Functions ¶
func FromInterval ¶
FromInterval converts a given pgtype.Interval instance into a time.Duration instance. It assumes the interval is set using microseconds, as that is how `ToInterval` will create them.
func FromTextArray ¶
FromTextArray converts an instance of pgtype.TextArray to a string array.
func Migrate ¶
func Migrate(action func(*migrate.Migrate) error, source *MigrationSource, db *sql.DB) error
Migrate performs the migration action given a source driver.
func MigrateDown ¶
func MigrateDown(s *MigrationSource, db *sql.DB) error
MigrateDown reverts all migrations from the migration source that have already been applied.
func MigrateUp ¶
func MigrateUp(s *MigrationSource, db *sql.DB) error
MigrateUp applies all migrations from the migration source that haven't been applied yet.
func ToInterval ¶
ToInterval converts a given time.Duration to a pgtype.Interval instance. Will panic if Set returns an error.
func ToTextArray ¶
ToTextArray converts a given string slice to a pgtype.TextArray instance. Will panic if Set returns an error.
Types ¶
type MigrationSource ¶
type MigrationSource struct {
// contains filtered or unexported fields
}
The MigrationSource type is used as a source of migration info for performing migration actions against a database.
func NewBindataMigration ¶
func NewBindataMigration(dbDriver func(db *sql.DB) (database.Driver, error), b *bindata.AssetSource) *MigrationSource
NewBindataMigration creates a migration from the provided bindata asset.
func NewDirectoryMigration ¶
func NewDirectoryMigration(dbDriver func(db *sql.DB) (database.Driver, error), dir string) *MigrationSource
NewDirectoryMigration creates a migration from the provided directory path. The parameter must be a directory.
Directories ¶
Path | Synopsis |
---|---|
Package badger provides an instrumented wrapper around a badger database.
|
Package badger provides an instrumented wrapper around a badger database. |
Package postgres is used to perform operations against postgres databases
|
Package postgres is used to perform operations against postgres databases |
Package sqlite is used to perform operations against sqlite databases
|
Package sqlite is used to perform operations against sqlite databases |