Skip to content

Commit

Permalink
rename 4 to 5 andjust golang code that was executed for 4th migration
Browse files Browse the repository at this point in the history
  • Loading branch information
dshulyak committed Sep 19, 2023
1 parent 2f4dcf9 commit 95ad452
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -1338,7 +1338,7 @@ func (app *App) setupDBs(ctx context.Context, lg log.Log) error {
sqlDB, err := sql.Open("file:"+filepath.Join(dbPath, dbFile),
sql.WithConnections(app.Config.DatabaseConnections),
sql.WithLatencyMetering(app.Config.DatabaseLatencyMetering),
sql.WithV4Migration(util.ExtractActiveSet),
sql.WithV5Migration(util.ExtractActiveSet),
)
if err != nil {
return fmt.Errorf("open sqlite db %w", err)
Expand Down
12 changes: 6 additions & 6 deletions sql/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ type conf struct {
enableLatency bool

// TODO: remove after state is pruned for majority
v4Migration func(Executor) error
v5Migration func(Executor) error
}

// WithConnections overwrites number of pooled connections.
Expand All @@ -78,9 +78,9 @@ func WithMigrations(migrations Migrations) Opt {
}
}

func WithV4Migration(cb func(Executor) error) Opt {
func WithV5Migration(cb func(Executor) error) Opt {
return func(c *conf) {
c.v4Migration = cb
c.v5Migration = cb
}
}

Expand Down Expand Up @@ -145,9 +145,9 @@ func Open(uri string, opts ...Opt) (*Database, error) {
if err != nil {
return nil, err
}
if before <= 3 && after == 4 && config.v4Migration != nil {
// v4 migration (active set extraction) needs the 3rd migration to execute first
if err := config.v4Migration(db); err != nil {
if before <= 4 && after == 5 && config.v5Migration != nil {
// v5 migration (active set extraction) needs the 4rd migration to execute first
if err := config.v5Migration(db); err != nil {
return nil, err
}
if err := Vacuum(db); err != nil {
Expand Down
4 changes: 0 additions & 4 deletions sql/migrations/0004_next.sql

This file was deleted.

1 change: 1 addition & 0 deletions sql/migrations/0004_v1.1.7.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE INDEX ballots_by_atx_by_layer ON ballots (atx, layer asc);
3 changes: 3 additions & 0 deletions sql/migrations/0005_next.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DELETE FROM proposals;
DELETE FROM proposal_transactions;
UPDATE certificates SET cert = NULL WHERE layer < 19000;

0 comments on commit 95ad452

Please sign in to comment.