Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CachedMigrationError ¶
func CachedMigrationError() string
CachedMigrationError returns the error message captured when the most recent migration attempt failed at startup. Empty string means migrations either succeeded or were never run.
func CachedMigrationVersion ¶
CachedMigrationVersion returns the migration version captured at startup. Returns (version, dirty, ok). ok is false if the version was never captured.
Note: when migrations fail mid-way, the cache may still be populated via a best-effort m.Version() call inside RunMigrationsWithOptions so the system info endpoint can surface the partial state. Check CachedMigrationError() to distinguish a clean version reading from a recorded-after-failure one.
func GetMigrationVersion ¶
GetMigrationVersion returns the current migration version
func RunMigrations ¶
RunMigrations executes all pending database migrations This should be called during application startup
func RunMigrationsWithOptions ¶
func RunMigrationsWithOptions(dsn string, opts MigrationOptions) error
RunMigrationsWithOptions executes all pending database migrations with custom options
Types ¶
type MigrationOptions ¶
type MigrationOptions struct {
// AutoRecoverDirty when true, automatically attempts to recover from dirty state
// by forcing to the previous version and retrying the migration
AutoRecoverDirty bool
// SQLiteDBPath is the raw filesystem path to the SQLite database file.
// When set, the migrator opens the DB directly via sql.Open instead of
// parsing a URL-based DSN, which avoids breakage when the path contains
// spaces (e.g. macOS "Application Support").
SQLiteDBPath string
}
MigrationOptions configures migration behavior