database

package
v0.0.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrLegacyDeleteInProgress = errors.New("legacy delete operation is already in progress")
View Source
var ErrSameSQLiteFile = errors.New("SQLite paths resolve to same SQLite file")

Functions

func AfterLegacyDelete

func AfterLegacyDelete(path string, action func() error) error

func CanonicalLegacySourcePath

func CanonicalLegacySourcePath(configured, persisted string) (string, error)

func CheckIntegrity

func CheckIntegrity(db *gorm.DB) error

func CreateInSafeBatches

func CreateInSafeBatches[T any](ctx context.Context, target *gorm.DB, values []T, conflict clause.OnConflict) error

func CreateInSafeBatchesCount

func CreateInSafeBatchesCount[T any](ctx context.Context, target *gorm.DB, values []T, conflict clause.OnConflict) (int64, error)

func InitializeFreshCore

func InitializeFreshCore(ctx context.Context, target *gorm.DB, now func() time.Time) error

func LegacyDeleteMarkerPath

func LegacyDeleteMarkerPath(path string) string

func QuickCheck

func QuickCheck(db *gorm.DB) error

func RetireCoreBillingProjectionTables added in v0.0.15

func RetireCoreBillingProjectionTables(ctx context.Context, core, logDB *gorm.DB) (bool, error)

RetireCoreBillingProjectionTables removes obsolete core rollups only after the version 1 log-owned daily backfill has durably completed.

func SplitManifestPath

func SplitManifestPath(legacyPath string) string

func ValidateLegacyCleanerTargets

func ValidateLegacyCleanerTargets(core, logDB *gorm.DB) error

func ValidatePaths

func ValidatePaths(corePath, logPath string) error

Types

type BootstrapOptions

type BootstrapOptions struct {
	AfterTable func(string) error
	Now        func() time.Time
}

type BootstrapResult

type BootstrapResult struct {
	Created    bool
	SourceKind LegacyLayout
	CopiedRows int64
}

func BootstrapCore

func BootstrapCore(ctx context.Context, source, target *gorm.DB, layout LegacyLayoutInfo, options BootstrapOptions) (BootstrapResult, error)

type Connector

type Connector struct{}

func NewConnector

func NewConnector() *Connector

func (*Connector) OpenCore

func (c *Connector) OpenCore(path string) (*gorm.DB, error)

func (*Connector) OpenCorePath

func (c *Connector) OpenCorePath(path string) (*gorm.DB, error)

func (*Connector) OpenExistingCore

func (c *Connector) OpenExistingCore(path string) (*gorm.DB, error)

func (*Connector) OpenExistingCorePath

func (c *Connector) OpenExistingCorePath(path string) (*gorm.DB, error)

func (*Connector) OpenExistingLog

func (c *Connector) OpenExistingLog(path string) (*gorm.DB, error)

func (*Connector) OpenExistingLogPath

func (c *Connector) OpenExistingLogPath(path string) (*gorm.DB, error)

func (*Connector) OpenLegacyReadOnly

func (c *Connector) OpenLegacyReadOnly(layout LegacyLayoutInfo) (*gorm.DB, error)

func (*Connector) OpenLog

func (c *Connector) OpenLog(path string) (*gorm.DB, error)

func (*Connector) OpenLogPath

func (c *Connector) OpenLogPath(path string) (*gorm.DB, error)

func (*Connector) ReadHistoryMigrationMarker

func (c *Connector) ReadHistoryMigrationMarker(path string) (models.HistoryMigration, bool, error)

type LegacyArtifact

type LegacyArtifact struct {
	Path        string `json:"path"`
	SizeBytes   int64  `json:"size_bytes"`
	Exists      bool   `json:"exists"`
	InUse       bool   `json:"in_use"`
	Available   bool   `json:"available"`
	LastError   string `json:"last_error"`
	CanDelete   bool   `json:"can_delete"`
	DeleteError string `json:"delete_error"`
}

func FindLegacyArtifact

func FindLegacyArtifact(legacyDBPath string) (LegacyArtifact, error)

type LegacyArtifactDeletionCommand

type LegacyArtifactDeletionCommand struct {
	FindArtifact   func() (LegacyArtifact, error)
	BuildValidator func() LegacyArtifactDeletionValidator
}

func (LegacyArtifactDeletionCommand) Delete

func (c LegacyArtifactDeletionCommand) Delete(confirmation string) error

type LegacyArtifactDeletionValidator

type LegacyArtifactDeletionValidator struct {
	CoreDB              *gorm.DB
	LogDB               *gorm.DB
	LogDatabaseReady    bool
	CoreDatabaseDSN     string
	LogDatabaseDSN      string
	ActiveLegacySources []string
}

func (LegacyArtifactDeletionValidator) Check

type LegacyFileCleaner

type LegacyFileCleaner struct {
	ExpectedPath             string
	MigrationState           string
	BatchRunning             func() bool
	ValidateTargets          func() error
	ValidateArtifactDeletion func() error
	// contains filtered or unexported fields
}

func (LegacyFileCleaner) DeleteArtifact

func (c LegacyFileCleaner) DeleteArtifact(path, confirmation string) error

func (LegacyFileCleaner) DeleteConfiguredSource

func (c LegacyFileCleaner) DeleteConfiguredSource(configuredPath, persistedPath, confirmation string) error

func (LegacyFileCleaner) DeletePath

func (c LegacyFileCleaner) DeletePath(path, confirmation string) error

type LegacyLayout

type LegacyLayout string
const (
	LegacyLayoutNone     LegacyLayout = "none"
	LegacyLayoutMonolith LegacyLayout = "monolith"
	LegacyLayoutV5Core   LegacyLayout = "v5_core"
)

type LegacyLayoutInfo

type LegacyLayoutInfo struct {
	Kind LegacyLayout
	Path string
}

func FindLegacyLayout

func FindLegacyLayout(dsn string) (LegacyLayoutInfo, error)

type ParsedSQLiteDSN

type ParsedSQLiteDSN struct {
	Base           string
	Query          url.Values
	FilesystemPath string
	Memory         bool
}

func ParseSQLiteDSN

func ParseSQLiteDSN(raw string) (ParsedSQLiteDSN, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL