Documentation ¶
Index ¶
- Constants
- Variables
- func NewGenericMigrateFunction(req string) func(context.Context, pool.Pooler, *Options) error
- func WithLogger(lg Logger) func(migrator *Migrator)
- func WithOptions(op *Options) func(migrator *Migrator)
- type EmbedFsLoader
- type Executor
- type LogLevel
- type LogWriter
- type Logger
- type LoggerConfig
- type MigrateFunc
- type Migration
- type MigrationFile
- type MigrationsCollection
- type Migrator
- type Options
- type RollbackFunc
Constants ¶
View Source
const LogPrefixDefault string = "Tarantool-Migrator"
View Source
const MigrationFilePrefixExcluded = "--"
View Source
const MigrationFileSuffixDown = "down"
View Source
const MigrationFileSuffixUp = "up"
Variables ¶
View Source
var DefaultLogger = NewLogger(log.New(os.Stdout, "", log.LstdFlags), LoggerConfig{ LogLevel: LogLevelInfo, Prefix: LogPrefixDefault, })
View Source
var DefaultOptions = &Options{ MigrationsSpace: "migrations", ReadMode: pool.ANY, WriteMode: pool.RW, }
View Source
var ErrMigrationIDDoesNotExist = errors.New("tried to migrate to an ID that doesn't exist")
View Source
var ErrMissingID = errors.New("missing ID in migration")
ErrMissingID is returned when the ID of migration is equal to ""
View Source
var ErrMissingMigrateFunc = errors.New("missing migrate function in migration")
View Source
var ErrMissingRollbackFunc = errors.New("missing rollback function in migration")
View Source
var ErrNoAppliedMigrations = errors.New("no applied migrations")
View Source
var ErrNoDefinedMigrations = errors.New("no defined migrations")
ErrNoDefinedMigrations is returned when no migrations are defined.
View Source
var ErrWrongMigrationCmdFormat = errors.New("wrong migration cmd format")
View Source
var ErrWrongMigrationFileFormat = errors.New("wrong migration file format")
View Source
var LuaFs embed.FS
View Source
var SilentLogger = NewLogger(log.New(os.Stdout, "", log.LstdFlags), LoggerConfig{ LogLevel: LogLevelSilent, Prefix: LogPrefixDefault, })
Functions ¶
func WithLogger ¶
func WithOptions ¶
Types ¶
type EmbedFsLoader ¶
type EmbedFsLoader struct {
// contains filtered or unexported fields
}
func NewEmbedFsLoader ¶
func NewEmbedFsLoader(fs embed.FS) *EmbedFsLoader
func (*EmbedFsLoader) LoadMigrations ¶
func (fl *EmbedFsLoader) LoadMigrations(path string) (MigrationsCollection, error)
type LogWriter ¶
type LogWriter interface {
Printf(string, ...interface{})
}
LogWriter log writer interface
type Logger ¶
type Logger interface { Info(ctx context.Context, msg string, args ...interface{}) Debug(ctx context.Context, msg string, args ...interface{}) }
func NewLogger ¶
func NewLogger(writer LogWriter, config LoggerConfig) Logger
type LoggerConfig ¶
type MigrateFunc ¶
MigrateFunc is the func signature for migrating.
type Migration ¶
type Migration struct { // ID is the migration identifier. Usually a timestamp like "201601021504". ID string // Migrate is a function that will br executed while running this migration. Migrate MigrateFunc // Rollback will be executed on rollback. Can be nil. Rollback RollbackFunc }
Migration represents a database migration (a modification to be made on the database).
type MigrationFile ¶
type MigrationFile struct {
// contains filtered or unexported fields
}
func NewMigrationFile ¶
func NewMigrationFile(path string, file fs.DirEntry) (*MigrationFile, error)
func (*MigrationFile) GetCmd ¶
func (mf *MigrationFile) GetCmd() string
func (*MigrationFile) GetName ¶
func (mf *MigrationFile) GetName() string
func (*MigrationFile) GetPath ¶
func (mf *MigrationFile) GetPath() string
type MigrationsCollection ¶
type MigrationsCollection []*Migration
func (*MigrationsCollection) Find ¶
func (m *MigrationsCollection) Find(migrationID string) (*Migration, error)
func (*MigrationsCollection) IsEmpty ¶
func (m *MigrationsCollection) IsEmpty() bool
type Migrator ¶
type Migrator struct {
// contains filtered or unexported fields
}
func NewMigrator ¶
func NewMigrator(tt pool.Pooler, migrations MigrationsCollection, options ...func(*Migrator)) *Migrator
type Options ¶
type Options struct { // Migrations space MigrationsSpace string // Tarantool instances list Instances []string // Transactions enabled flag TransactionsEnabled bool // Default mode for read requests ReadMode pool.Mode // Default mode for read-write requests WriteMode pool.Mode }
Options define options for all migrations.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.