db

package
v0.0.0-...-3226211 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2016 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Conn the active database connection
	Conn *sql.DB

	// ErrUnableToParseDBConnection is raised when there are missing or invalid details for the database connection.
	ErrUnableToParseDBConnection = errors.New("unable to parse database connection details")

	// ErrUnableToConnectToDB is raised when a connection to the database cannot be established.
	ErrUnableToConnectToDB = errors.New("unable to connect to the database")
)

Functions

func ConnString

func ConnString() string

ConnString returns the connection string for the database driver.

func CreateMigrationsTable

func CreateMigrationsTable() error

CreateMigrationsTable creates the migrations table in the database.

func DeleteMigration

func DeleteMigration(id string) error

DeleteMigration deletes a migration from the migrations table.

func DropMigrationsTable

func DropMigrationsTable() error

DropMigrationsTable drops the migrations table from the database.

func InitConnection

func InitConnection()

InitConnection initializes the database connection

func InsertMigration

func InsertMigration(id string) error

InsertMigration inserts a new migration into the migrations table.

func MigrationActive

func MigrationActive(id string) (bool, error)

MigrationActive queries the migrations table for the migration ID and returns true if a result is found.

func MigrationsTablePresent

func MigrationsTablePresent() bool

MigrationsTablePresent returns true if the migrations is not present in the database.

func UseDB

func UseDB() error

UseDB runs the `USE` SQL command, ensuring that all future SQL commands on the database connection use the named database.

func VerifyConnection

func VerifyConnection(c *sql.DB) error

VerifyConnection pings the database to verify a connection is established. If the connection cannot be established, it will retry with an exponential back off.

Types

This section is empty.

Jump to

Keyboard shortcuts

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