migration

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearRegistry

func ClearRegistry()

ClearRegistry clears the global migration registry (useful for testing)

func RegisterMigration

func RegisterMigration(name string, migration Migration)

RegisterMigration registers a migration in the global registry

Types

type Migration

type Migration struct {
	Up   func(schema contractsschema.Schema) error
	Down func(schema contractsschema.Schema) error
}

Migration represents a migration with Up and Down methods

type Migrator

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

Migrator handles database migrations.

func NewMigrator

func NewMigrator(config config.Config, orm contractsorm.Orm, schema *schema.Schema, paths []string) *Migrator

NewMigrator creates a new Migrator instance.

func (*Migrator) Create

func (m *Migrator) Create(name string) error

func (*Migrator) Fresh

func (m *Migrator) Fresh() error

func (*Migrator) Reset

func (m *Migrator) Reset() error

func (*Migrator) Rollback

func (m *Migrator) Rollback(step, batch int) error

func (*Migrator) Run

func (m *Migrator) Run() error

func (*Migrator) Status

func (m *Migrator) Status() ([]migration.Status, error)

type Repository

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

Repository manages migration records in the database.

func NewRepository

func NewRepository(config config.Config, orm contractsorm.Orm) *Repository

NewRepository creates a new Repository instance.

func (*Repository) CreateRepository

func (r *Repository) CreateRepository() error

func (*Repository) Delete

func (r *Repository) Delete(migrationName string) error

func (*Repository) DeleteRepository

func (r *Repository) DeleteRepository() error

func (*Repository) GetLast

func (r *Repository) GetLast() ([]migration.File, error)

func (*Repository) GetMigrations

func (r *Repository) GetMigrations() ([]migration.File, error)

func (*Repository) GetMigrationsByBatch

func (r *Repository) GetMigrationsByBatch(batch int) ([]migration.File, error)

func (*Repository) GetMigrationsByStep

func (r *Repository) GetMigrationsByStep(steps int) ([]migration.File, error)

func (*Repository) GetNextBatchNumber

func (r *Repository) GetNextBatchNumber() (int, error)

func (*Repository) GetRan

func (r *Repository) GetRan() ([]string, error)

func (*Repository) Log

func (r *Repository) Log(migrationName string, batch int) error

func (*Repository) RepositoryExists

func (r *Repository) RepositoryExists() bool

Jump to

Keyboard shortcuts

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