Documentation ¶
Index ¶
- Constants
- Variables
- func CreateFile(filePath, content string) error
- func InitializeMigrationsFolder(ctx *Context) error
- func NewMigrator(dbRepo DBRepo) *migrator
- func ReadLines(filePath string) ([]string, error)
- func SelectExtention(database Database) string
- func SelectSubDirectory(database Database) string
- type Context
- type DBRepo
- type Database
- type Generator
- type MigrationDBEntry
- type MigrationFileEntry
- func GenerateNextMigrations(lastMigrationNumber int, name string, numToGenerate int) []*MigrationFileEntry
- func LastMigration(ctx *Context) *MigrationFileEntry
- func LoadCommittedMigrations(ctx *Context) []*MigrationFileEntry
- func LoadUncommitedMigrations(ctx *Context) []*MigrationFileEntry
- func ParseMigrationEntry(migrationEntry string) (*MigrationFileEntry, error)
- type MigrationType
- type Migrations
Constants ¶
View Source
const (
DEFAULT_LOG_FILE = ".commit-status"
)
Variables ¶
View Source
var (
ErrInvalidMigration = errors.New("invalid migration")
)
Functions ¶
func CreateFile ¶
func NewMigrator ¶
func NewMigrator(dbRepo DBRepo) *migrator
func SelectExtention ¶
func SelectSubDirectory ¶
Types ¶
type Context ¶
type Context struct { WorkDir string LogFile string Database Database DryRun bool Migrations Migrations }
func NewContext ¶
func (*Context) LoadMigrationEntries ¶
func (*Context) WriteMigrationEntries ¶
type DBRepo ¶
type DBRepo interface { Exec(query string) error PushHistory(migration *MigrationDBEntry) error LoadHistory() ([]*MigrationDBEntry, error) InitMigrationTable() error DeleteMigrationTable() error }
type MigrationDBEntry ¶
type MigrationFileEntry ¶
type MigrationFileEntry struct { Number int Name string Committed bool UpFilePath string DownFilePath string }
func GenerateNextMigrations ¶
func GenerateNextMigrations(lastMigrationNumber int, name string, numToGenerate int) []*MigrationFileEntry
func LastMigration ¶
func LastMigration(ctx *Context) *MigrationFileEntry
func LoadCommittedMigrations ¶
func LoadCommittedMigrations(ctx *Context) []*MigrationFileEntry
func LoadUncommitedMigrations ¶
func LoadUncommitedMigrations(ctx *Context) []*MigrationFileEntry
TODO: optimize to read from last, and break when commit status is true
func ParseMigrationEntry ¶
func ParseMigrationEntry(migrationEntry string) (*MigrationFileEntry, error)
func (*MigrationFileEntry) EntryString ¶
func (r *MigrationFileEntry) EntryString() string
func (*MigrationFileEntry) FileNames ¶
func (r *MigrationFileEntry) FileNames(extention string) (string, string)
func (*MigrationFileEntry) LoadFileContent ¶
func (r *MigrationFileEntry) LoadFileContent() (string, string)
func (*MigrationFileEntry) String ¶
func (r *MigrationFileEntry) String() string
type MigrationType ¶
type MigrationType string
const ( MigrationUp MigrationType = "up" MigrationDown MigrationType = "down" )
type Migrations ¶
type Migrations []*MigrationFileEntry
Source Files ¶
Click to show internal directories.
Click to hide internal directories.