Skip to content

Commit 6ec4a2d

Browse files
authored
Move m6 to the m4 spot. (#303)
1 parent e7bf615 commit 6ec4a2d

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

idb/postgres/postgres_migrations.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,24 @@ import (
2323
"github.com/algorand/indexer/types"
2424
)
2525

26-
// rewardsMigrationIndex is the index of m5RewardsAndDatesPart2.
27-
const rewardsMigrationIndex = 5
26+
// rewardsMigrationIndex is the index of m6RewardsAndDatesPart2.
27+
const rewardsMigrationIndex = 6
2828

2929
func init() {
3030
migrations = []migrationStruct{
3131
{m0fixupTxid, false, "Recompute the txid with corrected algorithm."},
3232
{m1fixupBlockTime, true, "Adjust block time to UTC timezone."},
3333
{m2apps, true, "Update DB Schema for Algorand application support."},
3434
{m3acfgFix, false, "Recompute asset configurations with corrected merge function."},
35-
{m4RewardsAndDatesPart1, true, "Update DB Schema for cumulative account reward support and creation dates."},
36-
{m5RewardsAndDatesPart2, false, "Compute cumulative account rewards for all accounts."},
37-
{m6MarkTxnJSONSplit, true, "record round at which txn json recording changes, for future migration to fixup prior records"},
35+
36+
// Migrations for 2.3.1 release
37+
{m4MarkTxnJSONSplit, true, "record round at which txn json recording changes, for future migration to fixup prior records"},
38+
{m5RewardsAndDatesPart1, true, "Update DB Schema for cumulative account reward support and creation dates."},
39+
{m6RewardsAndDatesPart2, false, "Compute cumulative account rewards for all accounts."},
3840
}
3941

4042
// Verify ensure the constant is pointing to the right index
41-
var m5Ptr postgresMigrationFunc = m5RewardsAndDatesPart2
43+
var m5Ptr postgresMigrationFunc = m6RewardsAndDatesPart2
4244
a2 := fmt.Sprintf("%v", migrations[rewardsMigrationIndex].migrate)
4345
a1 := fmt.Sprintf("%v", m5Ptr)
4446
if a1 != a2 {
@@ -353,8 +355,8 @@ func m3acfgFixAsyncInner(db *IndexerDb, state *MigrationState, assetIds []int64)
353355
return -1, nil
354356
}
355357

356-
// m4RewardsAndDatesPart1 adds the new rewards_total column to the account table.
357-
func m4RewardsAndDatesPart1(db *IndexerDb, state *MigrationState) error {
358+
// m5RewardsAndDatesPart1 adds the new rewards_total column to the account table.
359+
func m5RewardsAndDatesPart1(db *IndexerDb, state *MigrationState) error {
358360
// Cache the round in the migration metastate
359361
round, err := db.GetMaxRound()
360362
if err != nil {
@@ -414,8 +416,8 @@ func addrToPercent(addr string) float64 {
414416
return float64(val) / (32 * 32 * 32) * 100
415417
}
416418

417-
// m5RewardsAndDatesPart2 computes the cumulative rewards for each account one at a time.
418-
func m5RewardsAndDatesPart2(db *IndexerDb, state *MigrationState) error {
419+
// m6RewardsAndDatesPart2 computes the cumulative rewards for each account one at a time.
420+
func m6RewardsAndDatesPart2(db *IndexerDb, state *MigrationState) error {
419421
db.log.Println("account cumulative rewards migration starting")
420422

421423
var feeSinkAddr string
@@ -1130,9 +1132,9 @@ func (mtxid *txidFiuxpMigrationContext) readHeaders(minRound, maxRound uint64) (
11301132

11311133
// Record round at which behavior changed for encoding txn.txn JSON.
11321134
// A future migration should go back and apply new encoding to prior txn rows then delete this row in metastate.
1133-
func m6MarkTxnJSONSplit(db *IndexerDb, state *MigrationState) error {
1135+
func m4MarkTxnJSONSplit(db *IndexerDb, state *MigrationState) error {
11341136
sqlLines := []string{
1135-
`INSERT INTO metastate (k,v) SELECT 'm6MarkTxnJSONSplit', m.v FROM metastate m WHERE m.k = 'state'`,
1137+
`INSERT INTO metastate (k,v) SELECT 'm4MarkTxnJSONSplit', m.v FROM metastate m WHERE m.k = 'state'`,
11361138
}
11371139
return sqlMigration(db, state, sqlLines)
11381140
}

0 commit comments

Comments
 (0)