Documentation ¶
Index ¶
- Constants
- Variables
- func OpenURL(url string) (database.Driver, error)
- func WithInstance(instance *gorqlite.Connection, config *Config) (database.Driver, error)
- type Config
- type Rqlite
- func (r *Rqlite) Close() error
- func (r *Rqlite) Drop() error
- func (r *Rqlite) Lock() error
- func (r *Rqlite) Open(url string) (database.Driver, error)
- func (r *Rqlite) Run(migration io.Reader) error
- func (r *Rqlite) SetVersion(version int, dirty bool) error
- func (r *Rqlite) Unlock() error
- func (r *Rqlite) Version() (version int, dirty bool, err error)
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 WithInstance ¶
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 ¶
Close closes the underlying database instance managed by the driver. Migrate will call this function only once per instance.
func (*Rqlite) Drop ¶
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 ¶
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 ¶
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 ¶
Run applies a migration to the database. migration is guaranteed to be not nil.
func (*Rqlite) SetVersion ¶
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 ¶
Unlock should release the lock. Migrate will call this function after all migrations have been run.