storecopy

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: AGPL-3.0 Imports: 25 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package storecopy copies a stopped farm's SQLite database into an empty PostgreSQL database, verbatim, in one PostgreSQL transaction, and verifies every table by row count and digest before committing. See docs/operations.md, Moving to PostgreSQL.

The schema is read from the live catalogs (schemainfo), not from a list kept here, so a new table or column is copied without a change to this package, and a column type it does not know how to copy is refused by name. SQL is built by concatenating identifiers read from those catalogs, each one double-quoted (quoteIdent doubles any embedded quote); every value travels as a bind parameter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	SQLitePath  string // the source; never written
	PostgresDSN string // the target; empty, or migrated by sqi with no rows in its tables
	Logger      *slog.Logger
}

Options says what to copy where.

type Result

type Result struct {
	Tables  []TableResult
	Elapsed time.Duration
}

Result is what a successful copy did, tables in the order they were copied.

func Copy

func Copy(ctx context.Context, o Options) (Result, error)

Copy checks every precondition of the copy (both databases locked, the source intact and at this binary's schema version, the target empty and of the same shape), then copies every table in one PostgreSQL transaction and verifies it before committing. Any failure after the preconditions rolls the transaction back, committing no sqi rows (a schema Copy migrated into an empty target stays).

type TableResult

type TableResult struct {
	Table string
	Rows  int64
}

TableResult is one table's copied and verified row count.

Jump to

Keyboard shortcuts

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