Skip to content

Commit

Permalink
keeper fix the main migration version check
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricfung committed Aug 12, 2024
1 parent c741ebf commit ae02184
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cmd/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func mtgFixKeeper(ctx context.Context, path string) {
}
defer txn.Rollback()

key := "FIX:bd9f968e2bfae8a376a6eab9d18df047e82bdb85:1"
key := "FIX:bd9f968e2bfae8a376a6eab9d18df047e82bdb85:2"
row := txn.QueryRowContext(ctx, "SELECT value FROM properties WHERE key=?", key)
err = row.Scan(&key)
if err == sql.ErrNoRows {
Expand Down
12 changes: 8 additions & 4 deletions keeper/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,15 @@ func (node *Node) getMigrateAsset(ctx context.Context, safe *store.Safe, assetId

func (node *Node) Migrate(ctx context.Context) error {
logger.Printf("keeper.Migrate() ...")
err := node.store.MigrateDepositCreated(ctx)
err := node.store.FixRequest(ctx)
logger.Printf("keeper.FixRequest() => %v", err)
if err != nil {
return fmt.Errorf("store.MigrateDepositCreated() => %v", err)
return err
}
err = node.store.MigrateDepositCreated(ctx)
logger.Printf("keeper.MigrateDepositCreated() => %v", err)
if err != nil {
return err
}
if node.store.CheckFullyMigrated(ctx) {
logger.Printf("keeper.CheckFullyMigrated() DONE")
Expand Down Expand Up @@ -78,8 +84,6 @@ func (node *Node) Migrate(ctx context.Context) error {

err = node.store.Migrate(ctx, ss, es)
logger.Printf("keeper.Migrate() => %v", err)
err = node.store.Migrate2(ctx)
logger.Printf("keeper.Migrate2() => %v", err)
return err
}

Expand Down
6 changes: 3 additions & 3 deletions keeper/store/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (s *SQLite3Store) CheckFullyMigrated(ctx context.Context) bool {
}
defer tx.Rollback()

key, val := "SCHEMA:VERSION:c12674b047a4eca95af046eff41c1e71c6655c7c", ""
key, val := "SCHEMA:VERSION:4fca1938ab13afa2f58bc3fabb4c653331b13476", ""
row := tx.QueryRowContext(ctx, "SELECT value FROM properties WHERE key=?", key)
err = row.Scan(&val)
if err == sql.ErrNoRows {
Expand Down Expand Up @@ -137,7 +137,7 @@ func (s *SQLite3Store) MigrateDepositCreated(ctx context.Context) error {
}

// FIXME remove this
func (s *SQLite3Store) Migrate2(ctx context.Context) error {
func (s *SQLite3Store) FixRequest(ctx context.Context) error {
s.mutex.Lock()
defer s.mutex.Unlock()

Expand All @@ -147,7 +147,7 @@ func (s *SQLite3Store) Migrate2(ctx context.Context) error {
}
defer tx.Rollback()

key, val := "SCHEMA:VERSION:bd9f968e2bfae8a376a6eab9d18df047e82bdb85:1", ""
key, val := "FIX:VERSION:bd9f968e2bfae8a376a6eab9d18df047e82bdb85:2", ""
row := tx.QueryRowContext(ctx, "SELECT value FROM properties WHERE key=?", key)
err = row.Scan(&val)
if err == nil || err != sql.ErrNoRows {
Expand Down

0 comments on commit ae02184

Please sign in to comment.