migrator

package
v0.0.50 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountDestructiveChanges

func CountDestructiveChanges(changes []schema.Change) (count int, descriptions []string)

func DescribeChange

func DescribeChange(change schema.Change) string

func EnsureDatabaseExists

func EnsureDatabaseExists(dsn string) error

func GenerateAtlasSQL

func GenerateAtlasSQL(ctx context.Context, driver migrate.Driver, changes []schema.Change) ([]string, error)

func GetDatabaseDSN

func GetDatabaseDSN(host, port, user, password, dbname, sslmode string) string

func GetDatabaseURL

func GetDatabaseURL(host, port, user, password, dbname, sslmode string) string

func IsDestructiveChange

func IsDestructiveChange(change schema.Change) bool

Types

type AtlasMigrator

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

AtlasMigrator handles migration generation using Atlas with simplified approach

func NewAtlasMigrator

func NewAtlasMigrator(config *DBConfig) *AtlasMigrator

func (*AtlasMigrator) GenerateMigration

func (m *AtlasMigrator) GenerateMigration(ctx context.Context, sourceDB *sql.DB, opts MigrationOptions) (*MigrationResult, error)

type DBConfig

type DBConfig struct {
	URL             string
	ConnMaxLifetime time.Duration
	MaxOpenConns    int
	MaxIdleConns    int
}

func NewDBConfig

func NewDBConfig(url string) *DBConfig

func (*DBConfig) Connect

func (cfg *DBConfig) Connect(ctx context.Context) (*sql.DB, error)

type MigrationOptions

type MigrationOptions struct {
	PackagePath         string
	OutputDir           string
	MigrationName       string
	DryRun              bool
	AllowDestructive    bool
	PushToDB            bool
	CreateDBIfNotExists bool
}

MigrationOptions contains options for migration generation

type MigrationResult

type MigrationResult struct {
	UpSQL          string
	DownSQL        string
	Changes        []schema.Change
	HasDestructive bool
	DestructiveOps []string
	UpFilePath     string
	DownFilePath   string
}

MigrationResult contains the results of migration generation

type MigrationReverser

type MigrationReverser struct{}

MigrationReverser handles the reversal of migration statements

func NewMigrationReverser

func NewMigrationReverser() *MigrationReverser

func (*MigrationReverser) ReverseSQL

func (mr *MigrationReverser) ReverseSQL(sql string) (string, error)

type SimplifiedAtlasMigrator

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

SimplifiedAtlasMigrator provides a simpler Atlas-based migration

func NewSimplifiedAtlasMigrator

func NewSimplifiedAtlasMigrator(config *DBConfig) *SimplifiedAtlasMigrator

func (*SimplifiedAtlasMigrator) GenerateMigrationSimple

func (m *SimplifiedAtlasMigrator) GenerateMigrationSimple(ctx context.Context, sourceDB *sql.DB, targetDDL string, createDBIfNotExists bool) (upSQL []string, changes []schema.Change, err error)

type TempDBManager

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

func NewTempDBManager

func NewTempDBManager(baseConfig *DBConfig) *TempDBManager

func (*TempDBManager) CreateTempDB

func (tm *TempDBManager) CreateTempDB(ctx context.Context, tempDBName string) (*sql.DB, func(), error)

Jump to

Keyboard shortcuts

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