Skip to content

Commit

Permalink
Update migrations to fix bug after removing migration 0
Browse files Browse the repository at this point in the history
  • Loading branch information
meyer9 committed Mar 7, 2018
1 parent 525ab4a commit 028cfd3
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 22 deletions.
4 changes: 2 additions & 2 deletions repo/migrations/Migration001.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (migration001) Up(repoPath string, dbPassword string, testnet bool) error {
if err != nil {
return err
}
_, err = f1.Write([]byte("2"))
_, err = f1.Write([]byte("1"))
if err != nil {
return err
}
Expand Down Expand Up @@ -169,7 +169,7 @@ func (migration001) Down(repoPath string, dbPassword string, testnet bool) error
if err != nil {
return err
}
_, err = f1.Write([]byte("1"))
_, err = f1.Write([]byte("0"))
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions repo/migrations/Migration001_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func TestMigration001(t *testing.T) {
if err != nil {
t.Error(err)
}
if string(repoVer) != "2" {
if string(repoVer) != "1" {
t.Error("Failed to write new repo version")
}

Expand Down Expand Up @@ -148,7 +148,7 @@ func TestMigration001(t *testing.T) {
if err != nil {
t.Error(err)
}
if string(repoVer) != "1" {
if string(repoVer) != "0" {
t.Error("Failed to write new repo version")
}

Expand Down
4 changes: 2 additions & 2 deletions repo/migrations/Migration002.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (migration002) Up(repoPath string, dbPassword string, testnet bool) error {
if err != nil {
return err
}
_, err = f1.Write([]byte("3"))
_, err = f1.Write([]byte("2"))
if err != nil {
return err
}
Expand Down Expand Up @@ -97,7 +97,7 @@ func (migration002) Down(repoPath string, dbPassword string, testnet bool) error
if err != nil {
return err
}
_, err = f1.Write([]byte("2"))
_, err = f1.Write([]byte("1"))
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions repo/migrations/Migration002_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestMigration002(t *testing.T) {
if err != nil {
t.Error(err)
}
if string(repoVer) != "3" {
if string(repoVer) != "2" {
t.Error("Failed to write new repo version")
}

Expand All @@ -65,7 +65,7 @@ func TestMigration002(t *testing.T) {
if err != nil {
t.Error(err)
}
if string(repoVer) != "2" {
if string(repoVer) != "1" {
t.Error("Failed to write new repo version")
}

Expand Down
4 changes: 2 additions & 2 deletions repo/migrations/Migration003.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (migration003) Up(repoPath string, dbPassword string, testnet bool) error {
if err != nil {
return err
}
_, err = f1.Write([]byte("4"))
_, err = f1.Write([]byte("3"))
if err != nil {
return err
}
Expand Down Expand Up @@ -85,7 +85,7 @@ func (migration003) Down(repoPath string, dbPassword string, testnet bool) error
if err != nil {
return err
}
_, err = f1.Write([]byte("3"))
_, err = f1.Write([]byte("2"))
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions repo/migrations/Migration003_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestMigration003(t *testing.T) {
if err != nil {
t.Error(err)
}
if string(repoVer) != "4" {
if string(repoVer) != "3" {
t.Error("Failed to write new repo version")
}

Expand All @@ -56,7 +56,7 @@ func TestMigration003(t *testing.T) {
if err != nil {
t.Error(err)
}
if string(repoVer) != "3" {
if string(repoVer) != "2" {
t.Error("Failed to write new repo version")
}

Expand Down
7 changes: 4 additions & 3 deletions repo/migrations/Migration004.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"database/sql"
"path"

_ "github.com/mutecomm/go-sqlcipher"
"os"

_ "github.com/mutecomm/go-sqlcipher"
)

// Migration004 variable is used in one of several repo version migrations
Expand Down Expand Up @@ -48,7 +49,7 @@ func (migration004) Up(repoPath string, dbPassword string, testnet bool) error {
if err != nil {
return err
}
_, err = f1.Write([]byte("5"))
_, err = f1.Write([]byte("4"))
if err != nil {
return err
}
Expand Down Expand Up @@ -120,7 +121,7 @@ func (migration004) Down(repoPath string, dbPassword string, testnet bool) error
if err != nil {
return err
}
_, err = f1.Write([]byte("4"))
_, err = f1.Write([]byte("3"))
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions repo/migrations/Migration004_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestMigration004(t *testing.T) {
if err != nil {
t.Error(err)
}
if string(repoVer) != "5" {
if string(repoVer) != "4" {
t.Error("Failed to write new repo version")
}

Expand All @@ -56,7 +56,7 @@ func TestMigration004(t *testing.T) {
if err != nil {
t.Error(err)
}
if string(repoVer) != "4" {
if string(repoVer) != "3" {
t.Error("Failed to write new repo version")
}
os.RemoveAll("./datastore")
Expand Down
7 changes: 4 additions & 3 deletions repo/migrations/Migration005.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package migrations
import (
"path"

_ "github.com/mutecomm/go-sqlcipher"
"io/ioutil"
"os"

_ "github.com/mutecomm/go-sqlcipher"
)

var Migration005 migration005
Expand All @@ -24,7 +25,7 @@ func (migration005) Up(repoPath string, dbPassword string, testnet bool) error {
return err
}

_, err = f1.Write([]byte("6"))
_, err = f1.Write([]byte("5"))
if err != nil {
return err
}
Expand All @@ -42,7 +43,7 @@ func (migration005) Down(repoPath string, dbPassword string, testnet bool) error
return err
}

_, err = f1.Write([]byte("5"))
_, err = f1.Write([]byte("4"))
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions repo/migrations/Migration005_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestMigration005(t *testing.T) {
if err != nil {
t.Error(err)
}
if string(repoVer) != "6" {
if string(repoVer) != "5" {
t.Error("Failed to write new repo version")
}

Expand All @@ -43,7 +43,7 @@ func TestMigration005(t *testing.T) {
if err != nil {
t.Error(err)
}
if string(repoVer) != "5" {
if string(repoVer) != "4" {
t.Error("Failed to write new repo version")
}
os.RemoveAll("./datastore")
Expand Down

0 comments on commit 028cfd3

Please sign in to comment.