mirror of https://github.com/status-im/migrate.git
Fix issue where version wouldn't correctly populate
This commit is contained in:
parent
28f6567fa0
commit
a191c8bf36
|
@ -49,6 +49,12 @@ func (driver *Driver) Close() error {
|
||||||
|
|
||||||
func (driver *Driver) ensureVersionTableExists() error {
|
func (driver *Driver) ensureVersionTableExists() error {
|
||||||
err := driver.session.Query("CREATE TABLE IF NOT EXISTS " + tableName + " (version counter, versionRow bigint primary key);").Exec()
|
err := driver.session.Query("CREATE TABLE IF NOT EXISTS " + tableName + " (version counter, versionRow bigint primary key);").Exec()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
driver.session.Query("UPDATE "+tableName+" SET version = version + 1 where versionRow = ?", versionRow).Exec()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -93,5 +99,5 @@ func (driver *Driver) Migrate(f file.File, pipe chan interface{}) {
|
||||||
func (driver *Driver) Version() (uint64, error) {
|
func (driver *Driver) Version() (uint64, error) {
|
||||||
var version int64
|
var version int64
|
||||||
err := driver.session.Query("SELECT version FROM "+tableName+" WHERE versionRow = ?", versionRow).Scan(&version)
|
err := driver.session.Query("SELECT version FROM "+tableName+" WHERE versionRow = ?", versionRow).Scan(&version)
|
||||||
return uint64(version), err
|
return uint64(version) - 1, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue