Compare commits
2 commits
Author | SHA1 | Date | |
---|---|---|---|
b83c7b1e17 | |||
08df526c02 |
1 changed files with 6 additions and 7 deletions
13
upgrader.go
13
upgrader.go
|
@ -43,7 +43,7 @@ func (upgrader *Upgrader) Version(dbName string) (version int, err error) {// {{
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
version, err = dbase.version()
|
version, err = dbase.Version()
|
||||||
return
|
return
|
||||||
}// }}}
|
}// }}}
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ func (dbase Database) verifySchemaEntry() (err error) {// {{{
|
||||||
|
|
||||||
return
|
return
|
||||||
}// }}}
|
}// }}}
|
||||||
func (dbase Database) version() (version int, err error) {// {{{
|
func (dbase Database) Version() (version int, err error) {// {{{
|
||||||
var rows *sql.Rows
|
var rows *sql.Rows
|
||||||
rows, err = dbase.db.Query(
|
rows, err = dbase.db.Query(
|
||||||
`SELECT version FROM `+dbase.upgrader.schema+`.schema ORDER BY version DESC LIMIT 1`,
|
`SELECT version FROM `+dbase.upgrader.schema+`.schema ORDER BY version DESC LIMIT 1`,
|
||||||
|
@ -130,8 +130,7 @@ func (dbase Database) version() (version int, err error) {// {{{
|
||||||
}// }}}
|
}// }}}
|
||||||
|
|
||||||
// AddDatabase sets a database up for the Run() function with verifying/creating the _db.schema table.
|
// AddDatabase sets a database up for the Run() function with verifying/creating the _db.schema table.
|
||||||
func (upgrader Upgrader) AddDatabase(host string, port int, dbName, user, pass string) (err error) {// {{{
|
func (upgrader Upgrader) AddDatabase(host string, port int, dbName, user, pass string) (db Database, err error) {// {{{
|
||||||
var db Database
|
|
||||||
if db, err = newDatabase(host, port, dbName, user, pass); err != nil {
|
if db, err = newDatabase(host, port, dbName, user, pass); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -151,11 +150,11 @@ func (upgrader Upgrader) Run() (err error) {// {{{
|
||||||
var version int
|
var version int
|
||||||
|
|
||||||
for dbName, dbase := range upgrader.databases {
|
for dbName, dbase := range upgrader.databases {
|
||||||
version, err = dbase.version()
|
version, err = dbase.Version()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
upgrader.logCallback("version", fmt.Sprintf("%s: %d", dbName, version))
|
upgrader.logCallback("version", fmt.Sprintf("%s.%s: %d", dbName, upgrader.schema, version))
|
||||||
|
|
||||||
for {
|
for {
|
||||||
version++
|
version++
|
||||||
|
@ -164,7 +163,7 @@ func (upgrader Upgrader) Run() (err error) {// {{{
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
upgrader.logCallback("exec", fmt.Sprintf("%s: %d", dbName, version))
|
upgrader.logCallback("exec", fmt.Sprintf("%s.%s: %d", dbName, upgrader.schema, version))
|
||||||
if _, err = dbase.db.Exec(string(sql)); err != nil {
|
if _, err = dbase.db.Exec(string(sql)); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue