migrate

package
v0.0.0-...-e943f8d Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultHost           = "localhost"
	DefaultUser           = "root"
	DefaultPort           = "26257"
	DefaultDatabase       = "service"
	DefaultMigrationTable = "schema_migrations"
)

Defaults for cockroachdb connection string

Variables

This section is empty.

Functions

This section is empty.

Types

type Cockroach

type Cockroach struct {
	MigrationsPath string
	// contains filtered or unexported fields
}

Cockroach wraps a database connection along with the necessary fields required to run migrations against said database.

func NewCockroach

func NewCockroach(path string, opts *CockroachConnectionOptions) (*Cockroach, error)

NewCockroach provides a Migrator to be ran against a CockroachDB databases

func (*Cockroach) Migrate

func (c *Cockroach) Migrate() error

Migrate performs the migrations within the given migration directory for CockroachDB.

type CockroachConnectionOptions

type CockroachConnectionOptions struct {
	*ConnectionOptions

	// MigrationTable optionally specifies the table name to store migration
	// history in. If not specified it'll default to `schema_migrations`.
	MigrationTable string
	// Secure informs the migrator that the connection is secured via SSL,
	// and that it should use the certificates from `SSL` struct paths when
	// verifying the identity and connecting to the database.
	Secure bool
	// SSL is used in conjunction with `Secure`.
	SSL *CockroachSSL
}

CockroachConnectionOptions expands on the standard ConnectionOptions and adds support for cockroachdb's secure connection along with a specified table to store migration information under

func (*CockroachConnectionOptions) ConnectionString

func (co *CockroachConnectionOptions) ConnectionString() (string, error)

ConnectionString concatenates the CockroachConnectionOptions down to a string, applying defaults to options that were not set ready to be used in a connection to the database

type CockroachSSL

type CockroachSSL struct {
	CertPath string
	KeyPath  string
	Mode     string
	RootCert string
}

CockroachSSL contains paths to the SSL keys on the disk for making a connection to a secured database.

type ConnectionOptions

type ConnectionOptions struct {
	Host     string
	Port     int
	User     string
	Pass     string
	Database string
	// contains filtered or unexported fields
}

ConnectionOptions define a collection of information that's required to connect to any database in order to be able to run migrations. This will be used by all `Migrator`s, either embedded in database-specific options, or wholly.

func (*ConnectionOptions) String

func (co *ConnectionOptions) String() (string, error)

ConnectionString concatenates the CockroachConnectionOptions down to a string, applying defaults to options that were not set ready to be used in a connection to the database

type Migrator

type Migrator interface {
	Migrate() error
}

Migrator defines database-specific migrators ready to run migrations against a single database.

Jump to

Keyboard shortcuts

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