Documentation
¶
Overview ¶
Package migration implements Fort's offline, encrypted SQLite/Postgres migration evidence. It deliberately does not apply semantic v1-to-v2 mappings: unresolved choices are reported and block an import.
Index ¶
- Constants
- Variables
- func SealArchive(archive Archive, key []byte, random io.Reader) ([]byte, error)
- type Archive
- func NewArchive(engine SourceEngine, schemaVersion, sourceDatabaseHash string, tables []Table, ...) (Archive, error)
- func OpenArchive(encoded, key []byte) (Archive, error)
- func SnapshotPostgres(ctx context.Context, databaseURL, accountID string, key []byte) (Archive, error)
- func SnapshotSQLite(ctx context.Context, path string, key []byte) (Archive, error)
- type Column
- type ImportPlan
- type MappingClass
- type Row
- type RowMapping
- type SourceEngine
- type Table
- type TableMapping
- type TableVerification
- type TimestampBounds
- type Value
- type ValueKind
- type VerificationReport
Constants ¶
const ( ArchiveFormatVersion = 1 ArchiveKeyBytes = 32 MaximumArchiveBytes = 512 << 20 )
Variables ¶
var ( ErrArchiveInvalid = errors.New("migration archive is invalid") ErrArchiveAuthentication = errors.New("migration archive authentication failed") ErrArchiveIntegrity = errors.New("migration archive integrity failed") ErrDatabaseNotQuiescent = errors.New("migration source database is not quiescent") ErrUnresolvedMappings = errors.New("migration has unresolved mappings") )
Functions ¶
Types ¶
type Archive ¶
type Archive struct {
FormatVersion int `json:"format_version"`
SourceEngine SourceEngine `json:"source_engine"`
SchemaVersion string `json:"schema_version"`
SourceDatabaseHash string `json:"source_database_hash"`
Tables []Table `json:"tables"`
TableCount int `json:"table_count"`
RowCount int64 `json:"row_count"`
ManifestMAC string `json:"manifest_mac"`
}
func NewArchive ¶
func NewArchive(engine SourceEngine, schemaVersion, sourceDatabaseHash string, tables []Table, key []byte) (Archive, error)
NewArchive freezes stable HMAC evidence over each logical record, table, and the complete manifest. The evidence remains inside the encrypted file.
func OpenArchive ¶
func SnapshotPostgres ¶
func SnapshotPostgres(ctx context.Context, databaseURL, accountID string, key []byte) (Archive, error)
SnapshotPostgres exports one account through a direct migration-operator connection. The session is repeatable-read and read-only; it never uses the runtime Store and cannot become a write path for a client or worker.
type ImportPlan ¶
type ImportPlan struct {
SourceEngine SourceEngine `json:"source_engine"`
SchemaVersion string `json:"schema_version"`
ManifestMAC string `json:"manifest_mac"`
TotalRows int64 `json:"total_rows"`
Counts map[MappingClass]int64 `json:"counts"`
Tables []TableMapping `json:"tables"`
Rows []RowMapping `json:"rows"`
Resolved bool `json:"resolved"`
}
func PlanPostgresImport ¶
func PlanPostgresImport(archive Archive) ImportPlan
func (ImportPlan) RequireResolved ¶
func (report ImportPlan) RequireResolved() error
type MappingClass ¶
type MappingClass string
const ( MappingReady MappingClass = "ready" MappingNeedsExplicitChoice MappingClass = "needs_explicit_choice" MappingLegacyRetained MappingClass = "legacy_retained" MappingIncompatible MappingClass = "incompatible" )
type RowMapping ¶
type RowMapping struct {
SourceTable string `json:"source_table"`
TargetTable string `json:"target_table,omitempty"`
RecordDigest string `json:"record_digest"`
Class MappingClass `json:"class"`
Reason string `json:"reason"`
}
type SourceEngine ¶
type SourceEngine string
const ( SourceSQLite SourceEngine = "sqlite" SourcePostgres SourceEngine = "postgres" )
type Table ¶
type Table struct {
Name string `json:"name"`
Columns []Column `json:"columns"`
Dependencies []string `json:"dependencies,omitempty"`
Rows []Row `json:"rows"`
Count int64 `json:"count"`
SchemaDigest string `json:"schema_digest"`
Digest string `json:"digest"`
IdentityMaxima map[string]string `json:"identity_maxima,omitempty"`
TimestampBounds map[string]TimestampBounds `json:"timestamp_bounds,omitempty"`
}
type TableMapping ¶
type TableVerification ¶
type TableVerification struct {
LogicalTable string `json:"logical_table"`
SourceTable string `json:"source_table"`
TargetTable string `json:"target_table"`
SourceCount int64 `json:"source_count"`
TargetCount int64 `json:"target_count"`
SourceDigest string `json:"source_digest"`
TargetDigest string `json:"target_digest"`
Matched bool `json:"matched"`
Reason string `json:"reason,omitempty"`
}
type TimestampBounds ¶
type Value ¶
Value is a lossless, engine-independent database scalar. Bytes use canonical raw-URL base64; JSON is canonical compact JSON.
type VerificationReport ¶
type VerificationReport struct {
SourceManifestMAC string `json:"source_manifest_mac"`
TargetManifestMAC string `json:"target_manifest_mac"`
Tables []TableVerification `json:"tables"`
Verified bool `json:"verified"`
}
func VerifyMigration ¶
func VerifyMigration(source, target Archive, key []byte) VerificationReport