goosedb

package
v0.0.0-...-0decd24 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTableDoesNotExist = errors.New("goosedb: table does not exist")

Functions

func EnsureDBVersion

func EnsureDBVersion(conf *DBConf, db *sql.DB) (int64, error)

EnsureDBVersion retrieves the current version for this DB, creating and initializing the DB version table if it doesn't exist.

func GetDBVersion

func GetDBVersion(conf *DBConf) (int64, error)

wrapper for EnsureDBVersion for callers that don't already have their own DB instance

func OpenDBFromDBConf

func OpenDBFromDBConf(conf *DBConf) (*sql.DB, error)

OpenDBFromDBConf wraps database/sql.DB.Open() and configures the newly opened DB based on the given DBConf.

Callers must Close() the returned DB.

func RunMigrations

func RunMigrations(conf *DBConf, migrationsDir string, target int64) error

func RunMigrationsOnDb

func RunMigrationsOnDb(conf *DBConf, migrationsDir string, target int64, db *sql.DB) (err error)

Runs migration on a specific database instance.

Types

type DBConf

type DBConf struct {
	MigrationsDir string
	Env           string
	Driver        DBDriver
	PgSchema      string
}

func NewDBConf

func NewDBConf(p, env string, pgschema string) (*DBConf, error)

extract configuration details from the given file

type DBDriver

type DBDriver struct {
	Name    string
	OpenStr string
	Import  string
	Dialect SqlDialect
}

DBDriver encapsulates the info needed to work with a specific database driver

func (*DBDriver) IsValid

func (drv *DBDriver) IsValid() bool

ensure we have enough info about this driver

type MySqlDialect

type MySqlDialect struct{}

type PostgresDialect

type PostgresDialect struct{}

type SqlDialect

type SqlDialect interface {
	// contains filtered or unexported methods
}

SqlDialect abstracts the details of specific SQL dialects for goose's few SQL specific statements

type Sqlite3Dialect

type Sqlite3Dialect struct{}

Jump to

Keyboard shortcuts

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