migration

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2025 License: MIT Imports: 10 Imported by: 0

README

appsap-migration

Getting Started

Migration lib for appsap-core framework

Installation

Run the following command to install the package:

go get github.com/mortired/appsap-migration

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	DatabaseURL    string
	MigrationsPath string
}

Config configuration for migrations

func LoadConfigFromEnv

func LoadConfigFromEnv() (*Config, error)

LoadConfigFromEnv loads migration configuration from environment variables

type IntegrationManager

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

IntegrationManager manages migration integration with application

func NewIntegrationManager

func NewIntegrationManager(manager *Migrator, options *IntegrationOptions) *IntegrationManager

NewIntegrationManager creates a new integration manager

func (*IntegrationManager) EnsureMigrations

func (im *IntegrationManager) EnsureMigrations(ctx context.Context) error

EnsureMigrations applies migrations if necessary

func (*IntegrationManager) HealthCheck

func (im *IntegrationManager) HealthCheck(ctx context.Context) error

HealthCheck checks migration system health

func (*IntegrationManager) WaitForDatabase

func (im *IntegrationManager) WaitForDatabase(ctx context.Context) error

WaitForDatabase waits for database availability

type IntegrationOptions

type IntegrationOptions struct {
	AutoMigrate   bool          // Automatically apply migrations on startup
	Timeout       time.Duration // Timeout for migrations
	RetryAttempts int           // Number of reconnection attempts
	RetryInterval time.Duration // Interval between attempts
}

IntegrationOptions options for migration integration with application

func DefaultIntegrationOptions

func DefaultIntegrationOptions() *IntegrationOptions

DefaultIntegrationOptions returns default options

type Migrator

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

Migrator manages database migrations

func New

func New(cfg *Config) (*Migrator, error)

New creates a new migrator

func NewWithEnv

func NewWithEnv() (*Migrator, error)

NewWithEnv creates a new migrator with automatic configuration loading from environment variables

func (*Migrator) Close

func (m *Migrator) Close() error

Close closes database connection

func (*Migrator) Down

func (m *Migrator) Down() error

Down rolls back all migrations

func (*Migrator) Force

func (m *Migrator) Force(version int) error

Force sets migration version

func (*Migrator) Status

func (m *Migrator) Status() error

Status shows migration status

func (*Migrator) Up

func (m *Migrator) Up() error

Up applies all migrations

func (*Migrator) Version

func (m *Migrator) Version() (int, bool, error)

Version returns current migration version

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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