Documentation
¶
Index ¶
Constants ¶
View Source
const ( ErrPathNotFound = utils.Error("Specified migration path not found") ErrInvalidPath = utils.Error("Specified migration path is not a directory") ErrInvalidFile = utils.Error("Specified migration path is not a file") ErrReadMigration = utils.Error("Error reading migration") MigrationFileExtension = ".sql" )
View Source
const ( ModuleBase = "base" MsgSkipMigration = iota + 1 MsgRunMigration MsgFinishedMigration MsgError ErrMigrationNameHashMismatch = utils.Error("Migration name or hash exists but they mismatch. Migration file was edited or renamed?") ErrMigrationExists = utils.Error("Migration already executed") ErrRegisterMigration = utils.Error("Migration executed successfully, but registration failed. Register manually") )
View Source
const (
ErrEmptyFolder = utils.Error("Specified folder is empty")
)
View Source
const (
ErrFileNotFound = utils.Error("file not found")
)
Variables ¶
This section is empty.
Functions ¶
func DefaultProgressFn ¶
Types ¶
type DiskSource ¶
type DiskSource struct {
Path string
}
func (*DiskSource) Read ¶
func (d *DiskSource) Read(name string) (*MigrationRecord, error)
Read a migration from disk
type EmbedSource ¶
type EmbedSource struct {
// contains filtered or unexported fields
}
func (*EmbedSource) List ¶
func (d *EmbedSource) List() ([]string, error)
List sql files (migrations)
func (*EmbedSource) Read ¶
func (d *EmbedSource) Read(name string) (*MigrationRecord, error)
Read a migration from disk
type Manager ¶
type Manager interface {
List(ctx context.Context) ([]MigrationRecord, error)
MigrationExists(ctx context.Context, name string, sha2 string) (bool, error)
RunMigration(ctx context.Context, m *MigrationRecord) error
RegisterMigration(ctx context.Context, m *MigrationRecord) error
Run(ctx context.Context, src Source, consoleFn ProgressFn) error
}
type MemorySource ¶ added in v0.1.4
type MemorySource struct {
// contains filtered or unexported fields
}
func NewMemorySource ¶ added in v0.1.4
func NewMemorySource() *MemorySource
func (*MemorySource) Add ¶ added in v0.1.4
func (d *MemorySource) Add(name string, content string)
Add a migration
func (*MemorySource) List ¶ added in v0.1.4
func (d *MemorySource) List() ([]string, error)
List sql files (migrations)
func (*MemorySource) Read ¶ added in v0.1.4
func (d *MemorySource) Read(name string) (*MigrationRecord, error)
Read a migration
type MigrationRecord ¶
type MigrationRecord struct {
Created time.Time `db:"created" ch:"created"`
Module string `db:"module" ch:"module"`
Name string `db:"name" ch:"name"`
SHA2 string `db:"sha2" ch:"sha2"`
Contents string `db:"contents" ch:"contents"`
}
func LoadMigration ¶
func LoadMigration(name string, content []byte) (*MigrationRecord, error)
LoadMigration from []byte slice
type ProgressFn ¶
Click to show internal directories.
Click to hide internal directories.