Documentation
¶
Overview ¶
Package migrate owns OtelContext's ordered main-database schema contract.
Index ¶
- Constants
- func AutoMigrate(db *gorm.DB, driver string, options storage.MigrateOptions) error
- func NormalizeDriver(driver string) string
- func SchemaFingerprint(ctx context.Context, db *gorm.DB, driver string, version int) (string, error)
- func SupportsVersioned(driver string) bool
- type Applied
- type BaselineResult
- type State
- type StateError
- type Status
Constants ¶
const ( // LedgerTable is shared by main storage and GraphRAG migrations. LedgerTable = "otelcontext_schema_migrations" // CurrentVersion is the exact relational schema version required by this binary. CurrentVersion = 3 )
const ( ExitOK = 0 ExitUsage = 2 ExitEmpty = 10 ExitUnmanaged = 11 ExitBehind = 12 ExitAhead = 13 ExitDirty = 14 ExitIncompatible = 15 ExitUnverified = 16 )
Exit codes are stable so deployment scripts do not need to parse prose.
Variables ¶
This section is empty.
Functions ¶
func AutoMigrate ¶
AutoMigrate is the single development and preview-driver schema owner. It deliberately does not stamp the versioned ledger: operators must validate and baseline a database before changing to DB_AUTOMIGRATE=false.
func NormalizeDriver ¶
NormalizeDriver returns the canonical driver name used by the registry.
func SchemaFingerprint ¶
func SchemaFingerprint(ctx context.Context, db *gorm.DB, driver string, version int) (string, error)
SchemaFingerprint hashes the required tables, columns, keys, and indexes. It deliberately excludes optional search indexes and the migration ledger.
func SupportsVersioned ¶
SupportsVersioned reports whether this driver has promoted migration definitions.
Types ¶
type Applied ¶
type Applied struct {
Version int
Name string
Checksum string
StartedAt time.Time
CompletedAt *time.Time
Dirty bool
}
Applied records one ledger entry without exposing the database row type.
type BaselineResult ¶
type BaselineResult struct {
Release string
RecordedVersion int
BeforeFingerprint string
AfterFingerprint string
Status Status
}
BaselineResult records the no-repair bridge from a published release.
type State ¶
type State string
State is the operator-visible compatibility state of the main database.
type StateError ¶
StateError carries the read-only status that made an operation fail closed.
func (*StateError) Error ¶
func (e *StateError) Error() string
type Status ¶
type Status struct {
Driver string
State State
ExpectedVersion int
ActualVersion int
Fingerprint string
Detail string
Applied []Applied
}
Status is the complete read-only compatibility result for the main database.
func Inspect ¶
Inspect reads the ledger and required relational structure without mutating it. A migration can commit between those two reads, so managed states are retried unless the ledger still matches the snapshot used for structural validation.
func RequireExact ¶
RequireExact performs the production startup compatibility gate.
func (Status) Description ¶
Description returns a compact stable line for logs and command output.