migrate

package
v0.0.0-...-5cfdd95 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2022 License: MIT Imports: 14 Imported by: 0

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