Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RedisMigration ¶
type RedisMigration struct { // ID is the identifier of this migration. It is used by the // framework to keep track of pending and finished migrations. // // It is recommended that you use something like "00000001-init" and // "00000002-next-migration" as identifier since this format allows you // to both sort your migrations based on the ID (see SortMigrationsByID) and // generally identify what your migration does. ID string // Up is the function implementing the actual migration logic. Up RedisUpFunc }
RedisMigration is a single migration to be run on a database.
func NewRedisMigration ¶
func NewRedisMigration(ID string, up RedisUpFunc) *RedisMigration
func SortMigrationsByID ¶ added in v0.3.0
func SortMigrationsByID(migrations []*RedisMigration) []*RedisMigration
SortMigrationsByID sorts the given migrations based on comparing their IDs.
strings.Compare is used as comparator. Look at the tests of this function if you want to see examples of how this is sorted.
The input slice is not modified in-place but instead a new, sorted slice is returned.
Once this module reaches v1 its sorting algorithm should not be changed.
func SortRedisMigrations ¶ added in v0.3.0
func SortRedisMigrations(migrations []*RedisMigration, cmp func(a, b *RedisMigration) int) []*RedisMigration
SortRedisMigrations is a helper function to sort the given migrations. You can supply your own comparator function to be used for sorting.
The input slice is not modified in-place but instead a new, sorted slice is returned.
type RedisMigrator ¶
type RedisMigrator struct {
// contains filtered or unexported fields
}
RedisMigrator runs migrations (RedisMigration) for a given redis.Client.
func NewRedisMigrator ¶
func NewRedisMigrator(client *redis.Client, prefix string) *RedisMigrator
NewRedisMigrator creates a new migrator using the given client.
The given prefix is used for internal keys which the migrator maintains to manage migrations.
func (*RedisMigrator) AddMigrations ¶
func (migrator *RedisMigrator) AddMigrations(m ...*RedisMigration) *RedisMigrator
func (*RedisMigrator) SetKeyPrefix ¶
func (migrator *RedisMigrator) SetKeyPrefix(prefix string) *RedisMigrator
SetKeyPrefix sets the prefix used on all keys used to manage migrations.