Skip to content

Commit

Permalink
chore: more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mistahj67 committed Aug 7, 2024
1 parent e570b41 commit b4f0bbe
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 13 deletions.
2 changes: 1 addition & 1 deletion cmd/api/src/database/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func (s *BloodhoundDB) Wipe(ctx context.Context) error {

func (s *BloodhoundDB) Migrate(ctx context.Context) error {
// Run the migrator
if err := migration.NewMigrator(s.db.WithContext(ctx)).Migrate(); err != nil {
if err := migration.NewMigrator(s.db.WithContext(ctx)).ExecuteStepwiseMigrations(); err != nil {
log.Errorf("Error during SQL database migration phase: %v", err)
return err
}
Expand Down
9 changes: 0 additions & 9 deletions cmd/api/src/database/migration/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package migration

import (
"embed"
"fmt"
"io/fs"

"github.com/specterops/bloodhound/src/version"
Expand Down Expand Up @@ -56,11 +55,3 @@ func NewMigrator(db *gorm.DB) *Migrator {
DB: db,
}
}

func (s *Migrator) Migrate() error {
if err := s.executeStepwiseMigrations(); err != nil {
return fmt.Errorf("failed to execute stepwise migrations: %w", err)
}

return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ func TestMigrator_Migrate(t *testing.T) {
manifest, err := migrator.GenerateManifest()
require.Nil(t, err)

assert.Nil(t, migrator.Migrate())
assert.Nil(t, migrator.ExecuteStepwiseMigrations())

lastVersionInManifest := manifest.VersionTable[len(manifest.VersionTable)-1]
latestMigration, err := migrator.LatestMigration()
Expand Down
4 changes: 2 additions & 2 deletions cmd/api/src/database/migration/stepwise.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (s *Migrator) RequiresMigration() (bool, error) {
}
}

// executeStepwiseMigrations will run all necessary migrations for a deployment.
// ExecuteStepwiseMigrations will run all necessary migrations for a deployment.
// It begins by checking if migration schema exists. If it does not, we assume the
// deployment is a new installation, otherwise we assume it may have migration updates.
//
Expand All @@ -156,7 +156,7 @@ func (s *Migrator) RequiresMigration() (bool, error) {
// and then build a manifest starting after the last successful version
//
// Once schema is verified and a manifest is created, we run ExecuteMigrations.
func (s *Migrator) executeStepwiseMigrations() error {
func (s *Migrator) ExecuteStepwiseMigrations() error {
var (
manifest Manifest
lastMigration model.Migration
Expand Down

0 comments on commit b4f0bbe

Please sign in to comment.