migrate

package
v0.0.0-...-e6ad4de Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: MIT Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenDB

func OpenDB() (*gorm.DB, error)

OpenDB initializes SQLite database connection.

Types

type Migration

type Migration struct {
	Logger *logrus.Logger
	// contains filtered or unexported fields
}

Migration is the top-level migration instance.

func NewMigration

func NewMigration(
	logger *logrus.Logger,
	repository *Repository,
	versionsDir string,
	verbose bool,
) *Migration

NewMigration creates an instance of Migration.

func (*Migration) FindMigrations

func (m *Migration) FindMigrations() (*PlannedMigration, error)

FindMigrations determine planned migrations.

func (*Migration) Status

func (m *Migration) Status() (table.Writer, error)

Status show migration status.

func (*Migration) Up

func (m *Migration) Up() error

Up migrates to the most recent version available.

type PlannedMigration

type PlannedMigration struct {
	Tasks []*Task
}

PlannedMigration migrations to be run.

type Repository

type Repository struct {
	*gorm.DB
	// contains filtered or unexported fields
}

Repository contains the DB controller of the Version table.

func NewRepository

func NewRepository(
	db *gorm.DB,
) *Repository

NewRepository creates an instance of Repository.

func (*Repository) Delete

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

Delete remove the given `Migration.Name` from the database,

func (*Repository) Find

func (r *Repository) Find() ([]*Version, error)

Find return all records from the database,

func (*Repository) FindByName

func (r *Repository) FindByName(name string) (*Version, error)

FindByName find the given `Migration.Name` from the database,

func (*Repository) First

func (r *Repository) First() (*Version, error)

First find the first `Migration` record from the database,

func (*Repository) Insert

func (r *Repository) Insert(name string) error

Insert add a new `Migration` record into the database,

func (*Repository) Last

func (r *Repository) Last() (*Version, error)

Last find the last `Migration` record from the database,

type Task

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

Task entrypoint executor.

func NewTask

func NewTask(
	entrypoint string,
	verbose bool,
) *Task

NewTask creates an instance of Task.

func (*Task) Run

func (t *Task) Run() error

Run execute the given task file.

type Version

type Version struct {
	gorm.Model
	ID   int64  `gorm:"primaryKey;autoIncrement;not null"`
	Name string `gorm:"type:varchar(255);not null; unique"`
}

Version type represents DB model.

Jump to

Keyboard shortcuts

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