Added Publisher.Version to enable comparisons in applications using this library
This commit is contained in:
parent
d290a67800
commit
2cb694f534
@ -19,11 +19,11 @@ func newDatabase(host string, port int, dbName, user, pass string) (dbase Databa
|
|||||||
|
|
||||||
func (dbase Database) sqlConnString() string {// {{{
|
func (dbase Database) sqlConnString() string {// {{{
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
"postgresql://%s:%s@%s:%d/%s?sslmode=disable",
|
"host=%s port=%d user=%s password=%s dbname=%s sslmode=disable",
|
||||||
dbase.Username,
|
|
||||||
dbase.Password,
|
|
||||||
dbase.Host,
|
dbase.Host,
|
||||||
dbase.Port,
|
dbase.Port,
|
||||||
|
dbase.Username,
|
||||||
|
dbase.Password,
|
||||||
dbase.DbName,
|
dbase.DbName,
|
||||||
)
|
)
|
||||||
}// }}}
|
}// }}}
|
||||||
|
11
upgrader.go
11
upgrader.go
@ -28,6 +28,17 @@ func (upgrader *Upgrader) SetLogCallback(callback func(string, string)) {// {{{
|
|||||||
func (upgrader *Upgrader) SetSqlCallback(callback func(string, int) ([]byte, bool)) {// {{{
|
func (upgrader *Upgrader) SetSqlCallback(callback func(string, int) ([]byte, bool)) {// {{{
|
||||||
upgrader.sqlCallback = callback
|
upgrader.sqlCallback = callback
|
||||||
}// }}}
|
}// }}}
|
||||||
|
// Version returns the current dbschema version for the given database name.
|
||||||
|
func (upgrader *Upgrader) Version(dbName string) (version int, err error) {// {{{
|
||||||
|
dbase, found := upgrader.databases[dbName]
|
||||||
|
if !found {
|
||||||
|
err = fmt.Errorf("Database %s not previously added to the upgrader", dbName)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
version, err = dbase.version()
|
||||||
|
return
|
||||||
|
}// }}}
|
||||||
|
|
||||||
func (dbase Database) createSchemaTable() (err error) {// {{{
|
func (dbase Database) createSchemaTable() (err error) {// {{{
|
||||||
dbase.upgrader.logCallback("create", fmt.Sprintf("%s, _db.schema", dbase.DbName))
|
dbase.upgrader.logCallback("create", fmt.Sprintf("%s, _db.schema", dbase.DbName))
|
||||||
|
Loading…
Reference in New Issue
Block a user