-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
72d13b9
commit 9098362
Showing
4 changed files
with
36 additions
and
2 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
File renamed without changes.
34 changes: 34 additions & 0 deletions
34
internal/dinosaur/pkg/migrations/20240703120000_add_secret_data_sum.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,34 @@ | ||
package migrations | ||
|
||
// Migrations should NEVER use types from other packages. Types can change | ||
// and then migrations run on a _new_ database will fail or behave unexpectedly. | ||
// Instead of importing types, always re-create the type in the migration, as | ||
// is done here, even though the same type is defined in pkg/api | ||
|
||
import ( | ||
"github.com/go-gormigrate/gormigrate/v2" | ||
"github.com/pkg/errors" | ||
"github.com/stackrox/acs-fleet-manager/pkg/db" | ||
"gorm.io/gorm" | ||
) | ||
|
||
func addSecretDataSum() *gormigrate.Migration { | ||
type CentralRequest struct { | ||
db.Model | ||
SecretDataSum string `json:"secret_data_sum"` | ||
} | ||
migrationID := "20240703120000" | ||
|
||
return &gormigrate.Migration{ | ||
ID: migrationID, | ||
Migrate: func(tx *gorm.DB) error { | ||
return addColumnIfNotExists(tx, &CentralRequest{}, "secret_data_sum") | ||
}, | ||
Rollback: func(tx *gorm.DB) error { | ||
return errors.Wrap( | ||
tx.Migrator().DropColumn(&CentralRequest{}, "secret_data_sum"), | ||
"failed to drop secret_data_sum column", | ||
) | ||
}, | ||
} | ||
} |
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