dbmigrator

package
v0.0.0-...-29e199f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2024 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Overview

Package dbmigrator defines the functionalities for database migrations.

Index

Constants

This section is empty.

Variables

View Source
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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL