Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultGormConfigurerProvider() fx.Annotated
- func Migrate(ctx context.Context, r *Registrar, v Versioner) error
- func Use()
- type AppliedMigration
- type GormVersioner
- func (v *GormVersioner) CreateVersionTableIfNotExist(ctx context.Context) error
- func (v *GormVersioner) GetAppliedMigrations(ctx context.Context) ([]AppliedMigration, error)
- func (v *GormVersioner) RecordAppliedMigration(ctx context.Context, version Version, description string, success bool, ...) error
- type Migration
- type MigrationFunc
- type MigrationVersion
- type Registrar
- type Version
- type Versioner
Constants ¶
View Source
const ( TagPreUpgrade = "pre_upgrade" TagPostUpgrade = "post_upgrade" )
Variables ¶
View Source
var Module = &bootstrap.Module{ Name: "migration", Precedence: bootstrap.CommandLineRunnerPrecedence, Options: []fx.Option{ fx.Provide(NewRegistrar), fx.Provide(NewGormVersioner), fx.Provide(provideMigrationRunner()), }, }
Functions ¶
Types ¶
type AppliedMigration ¶
type GormVersioner ¶
type GormVersioner struct {
// contains filtered or unexported fields
}
func (*GormVersioner) CreateVersionTableIfNotExist ¶
func (v *GormVersioner) CreateVersionTableIfNotExist(ctx context.Context) error
func (*GormVersioner) GetAppliedMigrations ¶
func (v *GormVersioner) GetAppliedMigrations(ctx context.Context) ([]AppliedMigration, error)
type Migration ¶
type Migration struct { Version Version Description string Func MigrationFunc Tags utils.StringSet }
func WithVersion ¶
func (*Migration) WithFunc ¶
func (m *Migration) WithFunc(f MigrationFunc) *Migration
type MigrationFunc ¶
type MigrationVersion ¶
type MigrationVersion struct { Version Version `gorm:"primaryKey"` Description string ExecutionTime time.Duration InstalledOn time.Time Success bool }
func (MigrationVersion) GetDescription ¶
func (v MigrationVersion) GetDescription() string
func (MigrationVersion) GetInstalledOn ¶
func (v MigrationVersion) GetInstalledOn() time.Time
func (MigrationVersion) GetVersion ¶
func (v MigrationVersion) GetVersion() Version
func (MigrationVersion) IsSuccess ¶
func (v MigrationVersion) IsSuccess() bool
type Registrar ¶
type Registrar struct {
// contains filtered or unexported fields
}
func NewRegistrar ¶
func NewRegistrar() *Registrar
func (*Registrar) AddMigrations ¶
type Versioner ¶
type Versioner interface { CreateVersionTableIfNotExist(ctx context.Context) error GetAppliedMigrations(ctx context.Context) ([]AppliedMigration, error) RecordAppliedMigration(ctx context.Context, version Version, description string, success bool, installedOn time.Time, executionTime time.Duration) error }
func NewGormVersioner ¶
Click to show internal directories.
Click to hide internal directories.