Skip to content
This repository has been archived by the owner on Jun 28, 2018. It is now read-only.

use mysql migrator interface in WithInstance #286

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 11 additions & 2 deletions database/mysql/mysql.go
Expand Up @@ -35,14 +35,23 @@ type Config struct {
}

type Mysql struct {
db *sql.DB
db MysqlMigrator
isLocked bool

config *Config
}

type MysqlMigrator interface {
Ping() error
Close() error
Begin() (*sql.Tx, error)
Query(query string, args ...interface{}) (*sql.Rows, error)
QueryRow(string, ...interface{}) *sql.Row
Exec(query string, args ...interface{}) (sql.Result, error)
}

// instance must have `multiStatements` set to true
func WithInstance(instance *sql.DB, config *Config) (database.Driver, error) {
func WithInstance(instance MysqlMigrator, config *Config) (database.Driver, error) {
if config == nil {
return nil, ErrNilConfig
}
Expand Down