Documentation
¶
Index ¶
- func Init(dir string) error
- func Merge(migrationsDir string, version string) (string, error)
- func ReadSchemaVersion(filePath string) (*semver.Version, error)
- func SplitFileKey(path string, fileKeys []string) (fileKey string, innerPath string, err error)
- func WriteFileAtomic(path string, data []byte) error
- func WriteFilesAtomic(files map[string][]byte) error
- func WriteSchemaVersion(filePath string, version *semver.Version) error
- type MigrateResult
- type MigrationMeta
- type RollbackBlockedError
- type ValidationIssue
- type ValidationResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Init ¶
Init scaffolds a new migrable project in the given directory. It creates migrable.toml, the migrations directory, and a next/ staging directory.
func Merge ¶
Merge combines staging files from next/ into a single versioned migration file. Returns the output file path.
func SplitFileKey ¶
SplitFileKey splits a dot-separated path into a file key and the inner path within that file. For single-file projects (one key), the full path is returned unchanged as the inner path. For multi-file projects, the first unescaped dot segment must match one of the file keys.
func WriteFileAtomic ¶
func WriteFilesAtomic ¶
WriteFilesAtomic writes multiple files transactionally. All files are first written to temp files in the same directories as their targets. Only after all temp files are written successfully are they renamed to their final paths. On any failure, all temp files are cleaned up.
Types ¶
type MigrateResult ¶
type MigrateResult struct {
Applied int
FromVersion *semver.Version
ToVersion *semver.Version
// Descriptions maps migration version to its description string.
Descriptions map[string]string
// FileChanges maps file key to changes (for dry-run output).
FileChanges map[string][]tomledit.Change
}
MigrateResult holds the outcome of a Migrate call.
type MigrationMeta ¶
func DiscoverMigrations ¶
func DiscoverMigrations(migrationsDir string) ([]MigrationMeta, error)
type RollbackBlockedError ¶
type RollbackBlockedError struct {
IrreversibleOps []string
}
RollbackBlockedError is returned when a rollback cannot proceed because one or more ops are marked as irreversible.
func (*RollbackBlockedError) Error ¶
func (e *RollbackBlockedError) Error() string
type ValidationIssue ¶
ValidationIssue describes a single problem found during validation.
type ValidationResult ¶
type ValidationResult struct {
FileCount int
Errors []ValidationIssue
Warnings []ValidationIssue
}
ValidationResult collects all errors and warnings from validation.
func Validate ¶
func Validate(migrationsDir string) (*ValidationResult, error)
Validate checks all migration files in migrationsDir (and next/ if it exists) for correctness. It collects all issues rather than stopping at the first.