migrator

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package migrator provides functionality to manage database migrations. It supports MySQL and ClickHouse databases, performing schema migrations using the golang-migrate library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

type Driver uint8

Driver represents a database driver.

const (
	MySQL Driver
	Clickhouse
)

func (Driver) String

func (d Driver) String() string

String returns the string representation of the driver.

type Migrator

type Migrator struct {
	// contains filtered or unexported fields
}

Migrator is responsible for migrating the database schema.

func NewAnalyticsMigrator

func NewAnalyticsMigrator(dsn string, logger *slog.Logger) (*Migrator, error)

NewAnalyticsMigrator returns a migrator for analytics databases.

func NewMigrator

func NewMigrator(dsn string, logger *slog.Logger) (*Migrator, error)

NewMigrator creates a new Migrator instance.

func (*Migrator) Close

func (m *Migrator) Close() (source, db error)

Close closes the source and db.

func (*Migrator) Drop

func (m *Migrator) Drop(ctx context.Context) error

Drop drops the database.

func (*Migrator) Up

func (m *Migrator) Up(canAutoMigrate bool) error

Up runs any pending migrations. if canAutoMigrate is false and there are pending migrations, an error is returned for manual safety.

Jump to

Keyboard shortcuts

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