Skip to content

Commit

Permalink
Remove unused tables
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmcgary committed Nov 20, 2024
1 parent dce8824 commit e51c00c
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ node_modules
/release
.release_version
chart_releases
/snapshots/**/*.sql
*.sql
*.dump
2 changes: 1 addition & 1 deletion pkg/eigenState/avsOperators/avsOperators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func Test_AvsOperatorState(t *testing.T) {
Scan(&states)

if statesRes.Error != nil {
t.Fatalf("Failed to fetch registered_avs_operators: %v", statesRes.Error)
t.Fatalf("Failed to fetch avs_operator_state_changes: %v", statesRes.Error)
}

assert.Equal(t, 1, len(states))
Expand Down
3 changes: 1 addition & 2 deletions pkg/eigenState/stakerDelegations/stakerDelegations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ func setup() (

func teardown(model *StakerDelegationsModel) {
model.DB.Exec("truncate table staker_delegation_changes cascade")
model.DB.Exec("truncate table delegated_stakers cascade")
model.DB.Exec("truncate table staker_delegation_changes cascade")
}

Expand Down Expand Up @@ -125,7 +124,7 @@ func Test_DelegatedStakersState(t *testing.T) {
Scan(&states)

if statesRes.Error != nil {
t.Fatalf("Failed to fetch delegated_stakers: %v", statesRes.Error)
t.Fatalf("Failed to fetch staker_delegation_changes: %v", statesRes.Error)
}

assert.Equal(t, 1, len(states))
Expand Down
27 changes: 27 additions & 0 deletions pkg/postgres/migrations/202411191947_cleanupUnusedTables/up.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package _202411191947_cleanupUnusedTables

import (
"database/sql"
"gorm.io/gorm"
)

type Migration struct {
}

func (m *Migration) Up(db *sql.DB, grm *gorm.DB) error {
queries := []string{
`drop table delegated_stakers`,
`drop table registered_avs_operators`,
}
for _, query := range queries {
_, err := db.Exec(query)
if err != nil {
return err
}
}
return nil
}

func (m *Migration) GetName() string {
return "202411191947_cleanupUnusedTables"
}
2 changes: 2 additions & 0 deletions pkg/postgres/migrations/migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
_202411120947_disabledDistributionRoots "github.com/Layr-Labs/sidecar/pkg/postgres/migrations/202411120947_disabledDistributionRoots"
_202411130953_addHashColumns "github.com/Layr-Labs/sidecar/pkg/postgres/migrations/202411130953_addHashColumns"
_202411131200_eigenStateModelConstraints "github.com/Layr-Labs/sidecar/pkg/postgres/migrations/202411131200_eigenStateModelConstraints"
_202411191947_cleanupUnusedTables "github.com/Layr-Labs/sidecar/pkg/postgres/migrations/202411191947_cleanupUnusedTables"
"go.uber.org/zap"
"gorm.io/gorm"
"time"
Expand Down Expand Up @@ -102,6 +103,7 @@ func (m *Migrator) MigrateAll() error {
&_202411120947_disabledDistributionRoots.Migration{},
&_202411130953_addHashColumns.Migration{},
&_202411131200_eigenStateModelConstraints.Migration{},
&_202411191947_cleanupUnusedTables.Migration{},
}

for _, migration := range migrations {
Expand Down

0 comments on commit e51c00c

Please sign in to comment.