Documentation
¶
Index ¶
- func AddSqlProvider(driver string, provider SqlProvider)
- func SetEnvPrefix(prefix string)
- func SetSchemaTableName(tableName string)
- type Config
- type ConfigFn
- type Migrator
- func (m *Migrator) Down(opt command.DownOption) error
- func (m *Migrator) Init(opt command.InitOption) error
- func (m *Migrator) SetSqlDB(db *sql.DB)
- func (m *Migrator) Show(opt command.ShowOption) error
- func (m *Migrator) Skip(opt command.SkipOption) error
- func (m *Migrator) Status(opt command.StatusOption) error
- func (m *Migrator) Up(opt command.UpOption) error
- type SqlProvider
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddSqlProvider ¶ added in v0.3.0
func AddSqlProvider(driver string, provider SqlProvider)
AddSqlProvider add database provider
func SetEnvPrefix ¶ added in v0.3.0
func SetEnvPrefix(prefix string)
SetEnvPrefix set environment prefix
func SetSchemaTableName ¶ added in v0.3.0
func SetSchemaTableName(tableName string)
SetSchemaTableName set schema table name
Types ¶
type ConfigFn ¶ added in v0.2.0
type ConfigFn func(c *Config)
ConfigFn is a function type for updating the configuration
type Migrator ¶ added in v0.2.2
type Migrator struct {
// contains filtered or unexported fields
}
Migrator manage the migration
func New ¶ added in v0.2.0
New creates a new Migrator instance, with optional configuration functions
- configFile: if not exist, will skip load it.
Example ¶
package main
import (
"github.com/gookit/goutil"
"github.com/gookit/miglite"
"github.com/gookit/miglite/internal/config"
"github.com/gookit/miglite/pkg/command"
)
func main() {
mig, err := miglite.New("miglite.yml", func(cfg *config.Config) {
// update config options
})
goutil.PanicIfErr(err) // handle error
// run up migrations
err = mig.Up(command.UpOption{
Yes: true, // dont confirm
// ... options
})
goutil.PanicIfErr(err) // handle error
// other operations
// init migrations schema
err = mig.Init(command.InitOption{
// ... options
})
goutil.PanicIfErr(err) // handle error
// run down migrations
err = mig.Down(command.DownOption{
// ... options
})
goutil.PanicIfErr(err)
err = mig.Status(command.StatusOption{
// ... options
})
goutil.PanicIfErr(err) // handle error
err = mig.Show(command.ShowOption{
// ... options
})
goutil.PanicIfErr(err) // handle error
err = mig.Skip(command.SkipOption{
// ... options
})
goutil.PanicIfErr(err) // handle error
}
Output:
func NewWithConfig ¶ added in v0.2.0
NewWithConfig creates a new Migrator instance with a pre-configured Config
func (*Migrator) Down ¶ added in v0.2.2
func (m *Migrator) Down(opt command.DownOption) error
Down runs the migration down operation.
func (*Migrator) Init ¶ added in v0.2.2
func (m *Migrator) Init(opt command.InitOption) error
Init initializes the migration schema
func (*Migrator) Show ¶ added in v0.2.2
func (m *Migrator) Show(opt command.ShowOption) error
Show displays all tables in the database.
func (*Migrator) Skip ¶ added in v0.2.2
func (m *Migrator) Skip(opt command.SkipOption) error
Skip skips some migration files.
type SqlProvider ¶ added in v0.3.0
type SqlProvider = database.SqlProvider
SqlProvider is the interface for database provider
Click to show internal directories.
Click to hide internal directories.

