Versions in this module Expand all Collapse all v0 v0.0.3 Oct 29, 2024 v0.0.2 Oct 24, 2024 v0.0.1 Oct 24, 2024 Changes in this version + const HashFileName + var DefaultFormatter = TemplateFormatter + var DisableChecksum = func() PlannerOption + var ErrCheckpointNotFound = errors.New("no checkpoint found") + 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: no pending migration files") + var ErrNoPlan = errors.New("sql/migrate: no plan for matched states") + var ErrNotCheckpoint = errors.New("not a checkpoint file") + 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 FileStmts(drv Driver, f File) ([]string, error) + func FilesLastIndex[F File](files []F, f func(F) 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 CheckpointDir interface + CheckpointFiles func() ([]File, error) + FilesFromCheckpoint func(string) ([]File, error) + WriteCheckpoint func(name, tag string, content []byte) error + type CheckpointFile interface + CheckpointTag func() (string, error) + IsCheckpoint func() bool + type ChecksumError struct + File string + Line int + Pos int + Reason Reason + Total int + func (err ChecksumError) Error() string + func (err ChecksumError) Is(target error) bool + 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 ExecOrder uint + const ExecOrderLinear + const ExecOrderLinearSkip + const ExecOrderNonLinear + 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) + func (e *Executor) ValidateDir(context.Context) error + type ExecutorOption func(*Executor) error + func WithAllowDirty(b bool) ExecutorOption + func WithBaselineVersion(v string) ExecutorOption + func WithExecOrder(o ExecOrder) 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 + func FilesFromLastCheckpoint(dir Dir) ([]File, error) + func SkipCheckpointFiles(all []File) []File + 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 HistoryNonLinearError struct + OutOfOrder []File + Pending []File + func (e HistoryNonLinearError) Error() string + type LocalDir struct + func NewLocalDir(path string) (*LocalDir, error) + func (d *LocalDir) CheckpointFiles() ([]File, error) + func (d *LocalDir) Checksum() (HashFile, error) + func (d *LocalDir) Files() ([]File, error) + func (d *LocalDir) FilesFromCheckpoint(name string) ([]File, error) + func (d *LocalDir) Open(name string) (fs.File, error) + func (d *LocalDir) Path() string + func (d *LocalDir) WriteCheckpoint(name, tag string, b []byte) error + func (d *LocalDir) WriteFile(name string, b []byte) error + type LocalFile struct + func NewLocalFile(name string, data []byte) *LocalFile + func (f *LocalFile) AddDirective(name string, args ...string) + func (f *LocalFile) Bytes() []byte + func (f *LocalFile) CheckpointTag() (string, error) + func (f *LocalFile) Desc() string + func (f *LocalFile) Directive(name string) (ds []string) + func (f *LocalFile) IsCheckpoint() bool + func (f *LocalFile) Name() string + func (f *LocalFile) StmtDecls() ([]*Stmt, error) + func (f *LocalFile) Stmts() ([]string, error) + func (f *LocalFile) Version() string + type LogCheck struct + Error error + Stmt string + type LogChecks struct + Name string + Stmts []string + type LogChecksDone struct + Error error + 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) CheckpointFiles() ([]File, error) + func (d *MemDir) Checksum() (HashFile, error) + func (d *MemDir) Close() error + func (d *MemDir) Files() ([]File, error) + func (d *MemDir) FilesFromCheckpoint(name string) ([]File, error) + func (d *MemDir) Open(name string) (fs.File, error) + func (d *MemDir) Reset() + func (d *MemDir) SyncWrites(fs ...func(string, []byte) error) + func (d *MemDir) WriteCheckpoint(name, tag string, b []byte) 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 + State *schema.Realm + 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 PlanMode uint8 + const PlanModeDeferred + const PlanModeDump + const PlanModeInPlace + const PlanModeUnset + func (m PlanMode) Is(m1 PlanMode) bool + type PlanOption func(*PlanOptions) + type PlanOptions struct + Indent string + Mode PlanMode + SchemaQualifier *string + type Planner struct + func NewPlanner(drv Driver, dir Dir, opts ...PlannerOption) *Planner + func (p *Planner) Checkpoint(ctx context.Context, name string) (*Plan, error) + func (p *Planner) CheckpointSchema(ctx context.Context, name string) (*Plan, error) + 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) WriteCheckpoint(plan *Plan, tag string) 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 PlanWithMode(m PlanMode) PlannerOption + func PlanWithSchemaQualifier(q string) PlannerOption + type Reason uint + const ReasonAdded + const ReasonEdited + const ReasonRemoved + func (r Reason) String() string + 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 Scanner struct + func (s *Scanner) Scan(input string) ([]*Stmt, error) + type ScannerOptions struct + MatchBegin bool + MatchBeginAtomic bool + MatchDollarQuote bool + 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 FileStmtDecls(drv Driver, f File) ([]*Stmt, error) + func Stmts(input string) ([]*Stmt, error) + func (s *Stmt) Directive(name string) (ds []string) + type StmtScanner interface + ScanStmts func(input string) ([]*Stmt, error) + 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)