storj/internal/dbutil/dbschema/snapshot.go

33 lines
702 B
Go
Raw Normal View History

2019-02-14 13:33:42 +00:00
// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package dbschema
// Snapshots defines a collection of snapshot
type Snapshots struct {
List []*Snapshot
}
// Snapshot defines a particular snapshot of schema and data.
type Snapshot struct {
Version int
Script string
*Schema
*Data
}
// Add adds a new snapshot.
func (snapshots *Snapshots) Add(snap *Snapshot) {
snapshots.List = append(snapshots.List, snap)
}
// FindVersion finds a snapshot with the specified version.
func (snapshots *Snapshots) FindVersion(version int) (*Snapshot, bool) {
for _, snap := range snapshots.List {
if snap.Version == version {
return snap, true
}
}
return nil, false
}