Documentation ¶
Index ¶
- func LEQ(a Version, b Version) bool
- func SQLChecksum(script string) string
- func Statements(script string) []string
- type CommandFunc
- type Info
- type LogFunc
- type Migration
- type Migrations
- type Migrator
- func (m *Migrator) Add(mig Migration)
- func (m *Migrator) AddGoMigration(version Version, description string, execute CommandFunc)
- func (m *Migrator) AddRepeatableGoMigration(description string, execute CommandFunc)
- func (m *Migrator) AddRepeatableSQLMigration(description string, script string)
- func (m *Migrator) AddSQLMigration(version Version, description string, script string)
- func (m *Migrator) Baseline(version Version, description string) error
- func (m *Migrator) Clean() error
- func (m *Migrator) Info() Info
- func (m *Migrator) Migrate() error
- func (m *Migrator) Repair()
- func (m *Migrator) Validate()
- type SQLiteSupport
- func (SQLiteSupport) Clean(db *sql.DB) error
- func (SQLiteSupport) CreateMigrationsTable(db *sql.DB) error
- func (SQLiteSupport) ExistsMigrationsTable(db *sql.DB) (bool, error)
- func (SQLiteSupport) ListMigrations(con *sql.DB) (Migrations, error)
- func (SQLiteSupport) RecordMigration(db *sql.DB, m Migration) error
- type StatementBuilder
- type Status
- type Support
- type Type
- type Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SQLChecksum ¶
func Statements ¶
Types ¶
type CommandFunc ¶
type Info ¶
type Info struct {
Migrations Migrations
}
type Migration ¶
type Migration struct { Rank int Version Version Description string Type Type Checksum string Date time.Time ExecutionTime int Status Status Execute CommandFunc `json:"-"` }
func (Migration) IsRepeatable ¶
type Migrations ¶
type Migrations []Migration
func (Migrations) String ¶
func (ms Migrations) String() string
type Migrator ¶
type Migrator struct {
// contains filtered or unexported fields
}
func (*Migrator) AddGoMigration ¶
func (m *Migrator) AddGoMigration(version Version, description string, execute CommandFunc)
func (*Migrator) AddRepeatableGoMigration ¶
func (m *Migrator) AddRepeatableGoMigration(description string, execute CommandFunc)
func (*Migrator) AddRepeatableSQLMigration ¶
func (*Migrator) AddSQLMigration ¶
func (*Migrator) Baseline ¶
Baselines an existing database, excluding all migrations upto and including baselineVersion. Baseline is for introducing Migrator to existing databases by baselining them at a specific version. The will cause Migrate to ignore all migrations upto and including the baseline version. Newer migrations will then be applied as usual.
func (*Migrator) Clean ¶
Drops all objects in configured schemas Clean is a great help in development and test. It will effectively give you a fresh start, by wiping your configured schemas completely clean. All objects (tables, views, procedures, ...) will be dropped. Needless to say: do not use against your production DB!
func (*Migrator) Info ¶
The details and status information about all the migrations. List lets you know where you stand. At a glance you will see which migrations have already been applied, which other ones are still pending, when they were executed and whether they were successful or not.
func (*Migrator) Repair ¶
func (m *Migrator) Repair()
Repairs the metadata table Repair is your tool to fix issues with the metadata table. It has two main uses: - Remove failed migration entries (only for databases that do NOT support DDL transactions)
func (*Migrator) Validate ¶
func (m *Migrator) Validate()
Validates the applied migrations against the available ones. Validate helps you verify that the migrations applied to the database match the ones available locally. This is very useful to detect accidental changes that may prevent you from reliably recreating the schema.
type SQLiteSupport ¶
type SQLiteSupport struct{}
func (SQLiteSupport) CreateMigrationsTable ¶
func (SQLiteSupport) CreateMigrationsTable(db *sql.DB) error
func (SQLiteSupport) ExistsMigrationsTable ¶
func (SQLiteSupport) ExistsMigrationsTable(db *sql.DB) (bool, error)
func (SQLiteSupport) ListMigrations ¶
func (SQLiteSupport) ListMigrations(con *sql.DB) (Migrations, error)
func (SQLiteSupport) RecordMigration ¶
func (SQLiteSupport) RecordMigration(db *sql.DB, m Migration) error
type StatementBuilder ¶
type StatementBuilder struct {
// contains filtered or unexported fields
}
func NewStatementBuilder ¶
func NewStatementBuilder() *StatementBuilder
func (*StatementBuilder) Append ¶
func (b *StatementBuilder) Append(line string)
func (*StatementBuilder) IsTerminated ¶
func (b *StatementBuilder) IsTerminated() bool
func (*StatementBuilder) Statement ¶
func (b *StatementBuilder) Statement() string