clmymigrate

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package clmymigrate implements the postgres migration logic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SnapshotMigrated

func SnapshotMigrated(sqlFile string) fx.Option

SnapshotMigrated configures the di for using snapshot migrations.

Types

type Config

type Config struct {
	// TemporaryDatabase can be set to cause the logic to create a random database name and initialize
	// it when running auto-migration. This is mostly useful for automated tests
	TemporaryDatabase bool `env:"TEMPORARY_DATABASE" envDefault:"false"`
	// AutoMigration can be set to true to cause the logic to automatically run migrations when started. This
	// is mostly useful for automated tests.
	AutoMigration bool `env:"AUTO_MIGRATION" envDefault:"false"`
	// the sql being generated for creating the temporary database
	CreateDatabaseFormat string `env:"CREATE_DATABASE_FORMAT" envDefault:"CREATE DATABASE %s"`
	// the sql being generated for dropping the temporary database
	DropDatabaseFormat string `env:"DROP_DATABASE_FORMAT" envDefault:"DROP DATABASE %s"`
}

Config configures the packaged logic.

type SnapshotMigrater

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

SnapshotMigrater uses a snapshot strategy to migrate.

func NewSnaphotMigrater

func NewSnaphotMigrater(
	cfg Config,
	logs *zap.Logger,
	rwcfg *mysql.Config,
	rocfg *mysql.Config,
	snapp SnapshotPath,
) (*SnapshotMigrater, error)

NewSnaphotMigrater inits the migrater.

func (SnapshotMigrater) Migrate

func (m SnapshotMigrater) Migrate(ctx context.Context) error

Migrate initializes the schema.

func (SnapshotMigrater) Reset

func (m SnapshotMigrater) Reset(ctx context.Context) error

Reset drops the schema.

type SnapshotPath

type SnapshotPath string

SnapshotPath types a string to hold the full snapshot sql.

Jump to

Keyboard shortcuts

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