Skip to content

Commit

Permalink
don't backup db for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sentriz committed Oct 10, 2023
1 parent f18151b commit 80fdc85
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/gonic/gonic.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ func main() {
defer dbc.Close()

err = dbc.Migrate(db.MigrationContext{
Production: true,
DBPath: *confDBPath,
OriginalMusicPath: confMusicPaths[0].path,
PlaylistsPath: *confPlaylistsPath,
Expand Down
4 changes: 4 additions & 0 deletions db/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
)

type MigrationContext struct {
Production bool
DBPath string
OriginalMusicPath string
PlaylistsPath string
Expand Down Expand Up @@ -721,5 +722,8 @@ func migratePlaylistsPaths(tx *gorm.DB, ctx MigrationContext) error {
}

func backupDBPre016(tx *gorm.DB, ctx MigrationContext) error {
if !ctx.Production {
return nil
}
return Dump(context.Background(), tx, fmt.Sprintf("%s.%d.bak", ctx.DBPath, time.Now().Unix()))
}

0 comments on commit 80fdc85

Please sign in to comment.