db

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2020 License: Unlicense Imports: 3 Imported by: 0

Documentation

Overview

Package db implements a Postgres client for applying, querying, and recording migrations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a migration database connection.

func Connect

func Connect(uri string) (*Client, error)

Connect connects to the Postgres database at the given uri.

func (*Client) Close

func (c *Client) Close() error

Close closes the underlying database connection.

func (*Client) Exec

func (c *Client) Exec(sql string) error

ApplyMigration executes the given statements against the database, and then records that the migration has been applied.

func (*Client) GetMigrations

func (c *Client) GetMigrations() ([]*Migration, error)

GetMigrations returns all migrations that have been applied to the database.

func (*Client) LogCompletedMigration

func (c *Client) LogCompletedMigration(name string) error

func (*Client) TryLock

func (c *Client) TryLock() (bool, error)

TryLock attempts to acquire an exclusive lock for running migrations on this database.

func (*Client) Unlock

func (c *Client) Unlock() (bool, error)

Unlock unlocks the exclusive migration lock.

type Migration

type Migration struct {
	Name string
}

Migration is a migration that's been applied to the database.

Jump to

Keyboard shortcuts

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