Documentation ¶
Index ¶
- Variables
- func DefaultTemplate() string
- func Migrate(ctx context.Context, io IO, db *sql.DB, migrationsDir string, ...) error
- func NewFile(io IO, migrationsDir string, id MigrationID, slug string, ...) (string, error)
- func Renumber(io IO, dir string, write bool) error
- func Setup(migrationsDir string) (string, error)
- type IO
- type MigrationID
- type Queryable
- type TemplateData
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNegativeID = errors.New("migration ID must not be negative") ErrDuplicateID = errors.New("duplicate migration ID") )
Functions ¶
func DefaultTemplate ¶
func DefaultTemplate() string
DefaultTemplate returns the default template contents.
func Migrate ¶
Migrate runs all unapplied migrations in ID order, least to greatest. It skips any migrations that have already been applied.
If upto is non-nil, this will also skip any migrations with IDs greater than that value.
Types ¶
type MigrationID ¶
type MigrationID int64
A MigrationID is a nonnegative integer that will be used to sort migrations.
This will often be a Unix timestamp in seconds, so it's represented as as an int64 for easy conversion. That technically allows negative numbers (although getting one in modern times would be concerning!), so use NewMigrationID to check for negative values.
func NewMigrationID ¶
func NewMigrationID(i int64) (MigrationID, error)
func (*MigrationID) Set ¶
func (m *MigrationID) Set(s string) error
func (*MigrationID) String ¶
func (m *MigrationID) String() string
func (*MigrationID) Type ¶
func (*MigrationID) Type() string
func (MigrationID) Width ¶
func (m MigrationID) Width() int
type TemplateData ¶
type TemplateData struct { ID MigrationID Slug string }
Click to show internal directories.
Click to hide internal directories.