migrations

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2024 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const (
	MIGRATION_TABLE_NAME = "_migrations"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Migration

type Migration interface {
	Name() string
	Order() int
	Up() bool
	Down() bool
}

type MigrationEntity

type MigrationEntity struct {
	ID         string    `json:"id"`
	ExecutedOn time.Time `json:"executed_on"`
	Name       string    `json:"name"`
	Status     bool      `json:"status"`
}

type MigrationsRepository

type MigrationsRepository interface {
	CreateTable() error
	GetAppliedMigrations() ([]MigrationEntity, error)
	SaveMigrationStatus(migration MigrationEntity) error
}

type SqlMigrationService

type SqlMigrationService struct {
	Context context.Context

	Migrations        *orderedmap.OrderedMap[int, Migration]
	AppliedMigrations []MigrationEntity
	Repository        MigrationsRepository
	// contains filtered or unexported fields
}

func NewMigrationService

func NewMigrationService(repo MigrationsRepository) *SqlMigrationService

func (*SqlMigrationService) Register

func (m *SqlMigrationService) Register(migration Migration) error

func (*SqlMigrationService) Run

func (m *SqlMigrationService) Run() error

func (*SqlMigrationService) WasApplied

func (m *SqlMigrationService) WasApplied(name string) bool

Jump to

Keyboard shortcuts

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