cockroachdb

package
v4.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: MIT Imports: 13 Imported by: 0

README

cockroachdb

cockroachdb://user:password@host:port/dbname?query (cockroach://, and crdb-postgres:// work, too)

URL Query WithInstance Config Description
x-migrations-table MigrationsTable Name of the migrations table
x-lock-table LockTable Name of the table which maintains the migration lock
x-force-lock ForceLock Force lock acquisition to fix faulty migrations which may not have released the schema lock (Boolean, default is false)
dbname DatabaseName The name of the database to connect to
user The user to sign in as
password The user's password
host The host to connect to. Values that start with / are for unix domain sockets. (default is localhost)
port The port to bind to. (default is 5432)
connect_timeout Maximum wait for connection, in seconds. Zero or not specified means wait indefinitely.
sslcert Cert file location. The file must contain PEM encoded data.
sslkey Key file location. The file must contain PEM encoded data.
sslrootcert The location of the root certificate file. The file must contain PEM encoded data.
sslmode Whether or not to use SSL (disable|require|verify-ca|verify-full)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilConfig      = fmt.Errorf("no config")
	ErrNoDatabaseName = fmt.Errorf("no database name")
)
View Source
var DefaultLockTable = "schema_lock"
View Source
var DefaultMigrationsTable = "schema_migrations"

Functions

func WithInstance

func WithInstance(instance *sql.DB, config *Config) (database.Driver, error)

Types

type CockroachDb

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

func (*CockroachDb) Close

func (c *CockroachDb) Close() error

func (*CockroachDb) Drop

func (c *CockroachDb) Drop() (err error)

func (*CockroachDb) Lock

func (c *CockroachDb) Lock() error

Locking is done manually with a separate lock table. Implementing advisory locks in CRDB is being discussed See: https://github.com/cockroachdb/cockroach/issues/13546

func (*CockroachDb) Open

func (c *CockroachDb) Open(url string) (database.Driver, error)

func (*CockroachDb) Run

func (c *CockroachDb) Run(migration io.Reader) error

func (*CockroachDb) SetVersion

func (c *CockroachDb) SetVersion(version int, dirty bool) error

func (*CockroachDb) Unlock

func (c *CockroachDb) Unlock() error

Locking is done manually with a separate lock table. Implementing advisory locks in CRDB is being discussed See: https://github.com/cockroachdb/cockroach/issues/13546

func (*CockroachDb) Version

func (c *CockroachDb) Version() (version int, dirty bool, err error)

type Config

type Config struct {
	MigrationsTable string
	LockTable       string
	ForceLock       bool
	DatabaseName    string
}

Jump to

Keyboard shortcuts

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