Versions in this module Expand all Collapse all v0 v0.0.3 May 23, 2023 v0.0.2 May 22, 2023 v0.0.1 May 19, 2023 Changes in this version + const HashFileName + var DefaultFormatter = TemplateFormatter + var DisableChecksum = func() PlannerOption + var ErrChecksumFormat = errors.New("checksum file format invalid") + var ErrChecksumMismatch = errors.New("checksum mismatch") + var ErrChecksumNotFound = errors.New("checksum file not found") + var ErrCleanCheckerUnsupported = errors.New("sql/migrate: driver does not support checking if database is clean") + var ErrNoPendingFiles = errors.New("sql/migrate: execute: nothing to do") + var ErrNoPlan = errors.New("sql/migrate: no plan for matched states") + var ErrRevisionNotExist = errors.New("sql/migrate: revision not found") + var ErrSnapshotUnsupported = errors.New("sql/migrate: driver does not support taking a database snapshot") + var WithFormatter = PlanFormat + func ArchiveDir(dir Dir) ([]byte, error) + func FilesLastIndex(files []File, f func(File) bool) int + func LogIntro(l Logger, revs []*Revision, files []File) + func LogNoPendingFiles(l Logger, revs []*Revision) + func Validate(dir Dir) error + func WriteSumFile(dir Dir, sum HashFile) error + type Change struct + Args []any + Cmd string + Comment string + Reverse any + Source schema.Change + func (c *Change) ReverseStmts() (cmd []string, err error) + type CleanChecker interface + CheckClean func(context.Context, *TableIdent) error + type Dir interface + Checksum func() (HashFile, error) + Files func() ([]File, error) + WriteFile func(string, []byte) error + func UnarchiveDir(arc []byte) (Dir, error) + type Driver interface + type Executor struct + func NewExecutor(drv Driver, dir Dir, rrw RevisionReadWriter, opts ...ExecutorOption) (*Executor, error) + func (e *Executor) Execute(ctx context.Context, m File) (err error) + func (e *Executor) ExecuteN(ctx context.Context, n int) (err error) + func (e *Executor) ExecuteTo(ctx context.Context, version string) (err error) + func (e *Executor) Pending(ctx context.Context) ([]File, error) + func (e *Executor) Replay(ctx context.Context, r StateReader, opts ...ReplayOption) (_ *schema.Realm, err error) + type ExecutorOption func(*Executor) error + func WithAllowDirty(b bool) ExecutorOption + func WithBaselineVersion(v string) ExecutorOption + func WithFromVersion(v string) ExecutorOption + func WithLogger(log Logger) ExecutorOption + func WithOperatorVersion(v string) ExecutorOption + type File interface + Bytes func() []byte + Desc func() string + Name func() string + StmtDecls func() ([]*Stmt, error) + Stmts func() ([]string, error) + Version func() string + type Formatter interface + Format func(*Plan) ([]File, error) + type HashFile []struct + func NewHashFile(files []File) (HashFile, error) + func (f *HashFile) UnmarshalText(b []byte) error + func (f HashFile) MarshalText() ([]byte, error) + func (f HashFile) Sum() string + func (f HashFile) SumByName(n string) (string, error) + type HistoryChangedError struct + File string + Stmt int + func (e HistoryChangedError) Error() string + type LocalDir struct + func NewLocalDir(path string) (*LocalDir, error) + func (d *LocalDir) Checksum() (HashFile, error) + func (d *LocalDir) Files() ([]File, error) + func (d *LocalDir) Open(name string) (fs.File, error) + func (d *LocalDir) Path() string + func (d *LocalDir) WriteFile(name string, b []byte) error + type LocalFile struct + func NewLocalFile(name string, data []byte) *LocalFile + func (f LocalFile) Bytes() []byte + func (f LocalFile) Desc() string + func (f LocalFile) Directive(name string) (ds []string) + func (f LocalFile) Name() string + func (f LocalFile) StmtDecls() ([]*Stmt, error) + func (f LocalFile) Stmts() ([]string, error) + func (f LocalFile) Version() string + type LogDone struct + type LogEntry interface + type LogError struct + Error error + SQL string + type LogExecution struct + Files []File + From string + To string + type LogFile struct + Desc string + File File + Skip int + Version string + type LogStmt struct + SQL string + type Logger interface + Log func(LogEntry) + type MemDir struct + func OpenMemDir(name string) *MemDir + func (d *MemDir) Checksum() (HashFile, error) + func (d *MemDir) Close() error + func (d *MemDir) Files() ([]File, error) + func (d *MemDir) Open(name string) (fs.File, error) + func (d *MemDir) WriteFile(name string, data []byte) error + type MissingMigrationError struct + Description string + Version string + func (e MissingMigrationError) Error() string + type NopLogger struct + func (NopLogger) Log(LogEntry) + type NopRevisionReadWriter struct + func (NopRevisionReadWriter) DeleteRevision(context.Context, string) error + func (NopRevisionReadWriter) Ident() *TableIdent + func (NopRevisionReadWriter) ReadRevision(context.Context, string) (*Revision, error) + func (NopRevisionReadWriter) ReadRevisions(context.Context) ([]*Revision, error) + func (NopRevisionReadWriter) WriteRevision(context.Context, *Revision) error + type NotCleanError struct + Reason string + func (e *NotCleanError) Error() string + type Plan struct + Changes []*Change + Name string + Reversible bool + Transactional bool + Version string + type PlanApplier interface + ApplyChanges func(context.Context, []schema.Change, ...PlanOption) error + PlanChanges func(context.Context, string, []schema.Change, ...PlanOption) (*Plan, error) + type PlanOption func(*PlanOptions) + type PlanOptions struct + Indent string + SchemaQualifier *string + type Planner struct + func NewPlanner(drv Driver, dir Dir, opts ...PlannerOption) *Planner + func (p *Planner) Plan(ctx context.Context, name string, to StateReader) (*Plan, error) + func (p *Planner) PlanSchema(ctx context.Context, name string, to StateReader) (*Plan, error) + func (p *Planner) WritePlan(plan *Plan) error + type PlannerOption func(*Planner) + func PlanFormat(fmt Formatter) PlannerOption + func PlanWithChecksum(b bool) PlannerOption + func PlanWithDiffOptions(opts ...schema.DiffOption) PlannerOption + func PlanWithIndent(indent string) PlannerOption + func PlanWithSchemaQualifier(q string) PlannerOption + type ReplayOption func(*replayConfig) + func ReplayToVersion(v string) ReplayOption + type RestoreFunc func(context.Context) error + type Revision struct + Applied int + Description string + Error string + ErrorStmt string + ExecutedAt time.Time + ExecutionTime time.Duration + Hash string + OperatorVersion string + PartialHashes []string + Total int + Type RevisionType + Version string + type RevisionReadWriter interface + DeleteRevision func(context.Context, string) error + Ident func() *TableIdent + ReadRevision func(context.Context, string) (*Revision, error) + ReadRevisions func(context.Context) ([]*Revision, error) + WriteRevision func(context.Context, *Revision) error + type RevisionType uint + const RevisionTypeBaseline + const RevisionTypeExecute + const RevisionTypeResolved + const RevisionTypeUnknown + func (r RevisionType) Has(f RevisionType) bool + func (r RevisionType) MarshalText() ([]byte, error) + func (r RevisionType) String() string + type Snapshoter interface + Snapshot func(context.Context) (RestoreFunc, error) + type StateReader interface + ReadState func(ctx context.Context) (*schema.Realm, error) + func Realm(r *schema.Realm) StateReader + func RealmConn(drv Driver, opts *schema.InspectRealmOption) StateReader + func Schema(s *schema.Schema) StateReader + func SchemaConn(drv Driver, name string, opts *schema.InspectOptions) StateReader + type StateReaderFunc func(ctx context.Context) (*schema.Realm, error) + func (f StateReaderFunc) ReadState(ctx context.Context) (*schema.Realm, error) + type Stmt struct + Comments []string + Pos int + Text string + func Stmts(input string) ([]*Stmt, error) + func (s *Stmt) Directive(name string) (ds []string) + type TableIdent struct + Name string + Schema string + type TemplateFormatter []struct + func NewTemplateFormatter(templates ...*template.Template) (TemplateFormatter, error) + func (t TemplateFormatter) Format(plan *Plan) ([]File, error)