Documentation ¶
Overview ¶
Package mysql is a MySQL changelog adapter.
Index ¶
- Variables
- type Connection
- type MySQL
- func (m *MySQL) BeginTx() (rove.Transaction, error)
- func (m *MySQL) ChangesetApplied(id, author, filename string) (*changeset.Record, error)
- func (m *MySQL) Changesets(reverse bool) ([]changeset.Record, error)
- func (m *MySQL) Count() (count int, err error)
- func (m *MySQL) Delete(id, author, filename string) error
- func (m *MySQL) Initialize() (err error)
- func (m *MySQL) Insert(id, author, filename string, dateexecuted time.Time, count int, ...) error
- func (m *MySQL) Rollback(tag string) (int, error)
- func (m *MySQL) Tag(id, author, filename, tag string) error
- func (m *MySQL) ToRecord(cs dbchangeset) *changeset.Record
- func (m *MySQL) Update(id, author, filename string, dateexecuted time.Time, count int, ...) error
- type Tx
Constants ¶
This section is empty.
Variables ¶
var ( // ErrChangelogFailure occurs when the connection is not set up properly. ErrChangelogFailure = errors.New("error with changelog setup") // ErrTransactionFuncMissing occurs when the transaction function is missing. ErrTransactionFuncMissing = errors.New("error transaction func is missing") )
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct { Hostname string `json:"Hostname" env:"DB_HOSTNAME"` Port int `json:"Port" env:"DB_PORT"` Username string `json:"Username" env:"DB_USERNAME"` Password string `json:"Password" env:"DB_PASSWORD"` Name string `json:"Database" env:"DB_NAME"` Parameter string `json:"Parameter" env:"DB_PARAMETER"` }
Connection holds the details for the MySQL connection.
func NewConnection ¶
func NewConnection(prefix string) (*Connection, error)
NewConnection returns the info required to make a connection to a MySQL database from environment variables. The optional prefix is used when reading environment variables.
func (Connection) Connect ¶
func (c Connection) Connect(includeDatabase bool) (*sqlx.DB, error)
Connect to the database.
func (Connection) DSN ¶
func (c Connection) DSN(includeDatabase bool) string
DSN returns the Data Source Name.
type MySQL ¶
type MySQL struct { DB *sqlx.DB TableName string InitializeQuery string TransactionFunc func(tx *sql.Tx) rove.Transaction }
MySQL is a MySQL database changelog.
func New ¶
func New(c *Connection) (m *MySQL, err error)
New connects to the database and returns an object that satisfies the rove.Changelog interface.
func (*MySQL) BeginTx ¶
func (m *MySQL) BeginTx() (rove.Transaction, error)
BeginTx starts a transaction.
func (*MySQL) ChangesetApplied ¶
ChangesetApplied returns the checksum from the database if it's found, an error if there was an issue, or nil with no error if it's not found.
func (*MySQL) Changesets ¶
Changesets returns a list of the changesets from the database in ascending order (false) or descending order (true).
func (*MySQL) Initialize ¶
Initialize will create the changelog table or return an error.
func (*MySQL) Insert ¶
func (m *MySQL) Insert(id, author, filename string, dateexecuted time.Time, count int, checksum, description, version string) error
Insert will insert a new record into the database.