package rqlite

import "github.com/golang-migrate/migrate/v4/database/rqlite"

Index

Constants

const (
	// DefaultMigrationsTable defines the default rqlite migrations table
	DefaultMigrationsTable = "schema_migrations"

	// DefaultConnectInsecure defines the default setting for connect insecure
	DefaultConnectInsecure = false
)

Variables

var ErrBadConfig = fmt.Errorf("bad parameter")

ErrBadConfig is returned if configuration was invalid

var ErrNilConfig = fmt.Errorf("no config")

ErrNilConfig is returned if no configuration was passed to WithInstance

Functions

func OpenURL

func OpenURL(url string) (database.Driver, error)

OpenURL creates a rqlite database driver from a connect URL

func WithInstance

func WithInstance(instance *gorqlite.Connection, config *Config) (database.Driver, error)

WithInstance creates a rqlite database driver with an existing gorqlite database connection and a Config struct

Types

type Config

type Config struct {
	// ConnectInsecure sets whether the connection uses TLS. Ineffectual when using WithInstance
	ConnectInsecure bool
	// MigrationsTable configures the migrations table name
	MigrationsTable string
}

Config defines the driver configuration

type Rqlite

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

func (*Rqlite) Close

func (r *Rqlite) Close() error

Close closes the underlying database instance managed by the driver. Migrate will call this function only once per instance.

func (*Rqlite) Drop

func (r *Rqlite) Drop() error

Drop deletes everything in the database. Note that this is a breaking action, a new call to Open() is necessary to ensure subsequent calls work as expected.

func (*Rqlite) Lock

func (r *Rqlite) Lock() error

Lock should acquire a database lock so that only one migration process can run at a time. Migrate will call this function before Run is called. If the implementation can't provide this functionality, return nil. Return database.ErrLocked if database is already locked.

func (*Rqlite) Open

func (r *Rqlite) Open(url string) (database.Driver, error)

Open returns a new driver instance configured with parameters coming from the URL string. Migrate will call this function only once per instance.

func (*Rqlite) Run

func (r *Rqlite) Run(migration io.Reader) error

Run applies a migration to the database. migration is guaranteed to be not nil.

func (*Rqlite) SetVersion

func (r *Rqlite) SetVersion(version int, dirty bool) error

SetVersion saves version and dirty state. Migrate will call this function before and after each call to Run. version must be >= -1. -1 means NilVersion.

func (*Rqlite) Unlock

func (r *Rqlite) Unlock() error

Unlock should release the lock. Migrate will call this function after all migrations have been run.

func (*Rqlite) Version

func (r *Rqlite) Version() (version int, dirty bool, err error)

Version returns the currently active version and if the database is dirty. When no migration has been applied, it must return version -1. Dirty means, a previous migration failed and user interaction is required.

Source Files

rqlite.go

Version
v4.18.2 (latest)
Published
Jan 27, 2025
Platform
js/wasm
Imports
11 packages
Last checked
1 week ago

Tools for package owners.