Documentation
¶
Index ¶
- Variables
- type Console
- type File
- type Migration
- func (m *Migration) ApplyFile(ctx context.Context, entity *entity.Migration, fileName string, safely bool) error
- func (m *Migration) ApplySQL(ctx context.Context, safely bool, version, upSQL string) error
- func (m *Migration) BeginCommand(sqlQuery string) time.Time
- func (m *Migration) EndCommand(start time.Time)
- func (m *Migration) ExecQuery(ctx context.Context, sqlQuery string) error
- func (m *Migration) Exists(ctx context.Context, version string) (bool, error)
- func (m *Migration) InitializeTableHistory(ctx context.Context) error
- func (m *Migration) Migrations(ctx context.Context, limit int) (entity.Migrations, error)
- func (m *Migration) NewMigrations(ctx context.Context) (entity.Migrations, error)
- func (m *Migration) RevertFile(ctx context.Context, entity *entity.Migration, fileName string, safely bool) error
- func (m *Migration) RevertSQL(ctx context.Context, safely bool, version, downSQL string) error
- func (m *Migration) SQLQueryOutput(sqlQuery string) string
- type Options
- type Repository
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrMigrationVersionReserved = errors.New("migration version reserved")
Functions ¶
This section is empty.
Types ¶
type Console ¶
type Console interface {
Confirm(s string) bool
Info(message string)
InfoLn(message string)
Infof(message string, a ...any)
Success(message string)
SuccessLn(message string)
Successf(message string, a ...any)
Warn(message string)
WarnLn(message string)
Warnf(message string, a ...any)
Error(message string)
ErrorLn(message string)
Errorf(message string, a ...any)
Fatal(err error)
NumberPlural(count int, one, many string) string
}
type Migration ¶
type Migration struct {
// contains filtered or unexported fields
}
func NewMigration ¶
func NewMigration( options *Options, console Console, file File, repo Repository, ) *Migration
func (*Migration) EndCommand ¶
func (*Migration) InitializeTableHistory ¶
func (*Migration) Migrations ¶
func (*Migration) NewMigrations ¶
func (*Migration) RevertFile ¶
func (*Migration) SQLQueryOutput ¶
type Repository ¶
type Repository interface {
// ExistsMigration returns true if version of migration exists
ExistsMigration(ctx context.Context, version string) (bool, error)
// Migrations returns applied migrations history.
Migrations(ctx context.Context, limit int) (entity.Migrations, error)
// HasMigrationHistoryTable returns true if migration history table exists.
HasMigrationHistoryTable(ctx context.Context) (exists bool, err error)
// InsertMigration inserts the new migration record.
InsertMigration(ctx context.Context, version string) error
// RemoveMigration removes the migration record.
RemoveMigration(ctx context.Context, version string) error
// ExecQuery executes a query without returning any rows.
// The args are for any placeholder parameters in the query.
ExecQuery(ctx context.Context, query string, args ...any) error
ExecQueryTransaction(ctx context.Context, fnTx func(ctx context.Context) error) error
DropMigrationHistoryTable(ctx context.Context) error
CreateMigrationHistoryTable(ctx context.Context) error
MigrationsCount(ctx context.Context) (int, error)
TableNameWithSchema() string
}
Click to show internal directories.
Click to hide internal directories.