Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Migrator ¶
type Migrator struct {
// contains filtered or unexported fields
}
func NewMigrator ¶
func NewMigrator(logger *zap.Logger, repository database.Repository, config *conf.MigrationConfig) *Migrator
func (*Migrator) Migrate ¶
Migrate performs database migrations based on the configuration and current state of the database. It handles both "up" and "down" migrations, validates migrations if configured, and ensures the schema history table exists. The function operates within a distributed lock to prevent concurrent migrations.
Steps:
- Load migrations and hooks from the filesystem.
- Ensure the schema history table exists.
- Determine the latest applied migration version.
- Validate migrations (if enabled in the configuration).
- Determine the target migration version (destination).
- Execute the appropriate migration (up or down) based on the configuration.
- Log errors and warnings throughout the process.
Click to show internal directories.
Click to hide internal directories.