Documentation ¶
Overview ¶
Package dbmigrator defines the functionalities for database migrations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrMigrationInProgress = errors.New("there is already a migration in progress")
Functions ¶
This section is empty.
Types ¶
type DbMigrator ¶
type DbMigrator struct {
// contains filtered or unexported fields
}
DbMigrator handles database migrations.
func NewDbMigrator ¶
func NewDbMigrator(options DbMigratorOptions) (*DbMigrator, error)
func (DbMigrator) Migrate ¶
func (d DbMigrator) Migrate(ctx context.Context, migration Migration) error
Migrate executes the database migration process. It initializes the migration process, obtains the current schema version, and migrates the database to the target version.
func (DbMigrator) MigrateFromFiles ¶
func (d DbMigrator) MigrateFromFiles(ctx context.Context, input MigrateFromFilesInput) error
MigrateFromFiles migrates the database using migration files. It reads migration steps from files specified in the input MigrateFromFilesInput and executes them sequentially.
type DbMigratorOptions ¶
type DbMigratorOptions struct {
Connection sql.Connection
}
DbMigratorOptions defines the options to configure a DbMigrator.
type MigrateFromFilesInput ¶
type MigrateFromFilesInput struct { FS fs.ReadDirFS TargetVersion *int MigrationsTablePrefix *string }
MigrateFromFilesInput defines the input data to migrate database from files.
type Migration ¶
type Migration struct { Steps []MigrationStep TargetVersion int MigrationsTablePrefix *string }
Migration defines a database migration.
type MigrationStep ¶
type MigrationStep struct { UpFile io.ReadCloser DownFile io.ReadCloser VersionDescription string }
MigrationStep defines the step of a migration process.