-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add delta table for delegated stakers
- Loading branch information
1 parent
1733e8f
commit dc4564f
Showing
5 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
internal/sqlite/migrations/202409181340_stakerDelegationDelta/up.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package _202409181340_stakerDelegationDelta | ||
|
||
import ( | ||
"gorm.io/gorm" | ||
) | ||
|
||
type SqliteMigration struct { | ||
} | ||
|
||
func (m *SqliteMigration) Up(grm *gorm.DB) error { | ||
query := ` | ||
create table if not exists staker_delegation_changes ( | ||
staker TEXT NOT NULL, | ||
operator TEXT NOT NULL, | ||
delegated INTEGER NOT NULL, | ||
block_number INTEGER NOT NULL, | ||
log_index INTEGER NOT NULL, | ||
unique(staker, operator, delegated, log_index) | ||
) | ||
` | ||
res := grm.Exec(query) | ||
if res.Error != nil { | ||
return res.Error | ||
} | ||
return nil | ||
} | ||
|
||
func (m *SqliteMigration) GetName() string { | ||
return "202409181340_stakerDelegationDelta" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters