importer

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package importer copies the collections and the data of a PocketBase SQLite pb_data directory into a popgres (Postgres) app.

It is the only popgres package allowed to depend on a SQLite driver.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyStorage

func CopyStorage(pbDataDir string, popgresDataDir string) error

CopyStorage copies the local storage files of the PocketBase pb_data directory into the popgres data directory.

Types

type Options

type Options struct {
	// SkipLogs skips the import of the auxiliary.db request logs.
	SkipLogs bool

	// Force allows importing into a database that already has non-system collections.
	Force bool
}

Options defines the import options.

type Report

type Report struct {
	// Collections lists the names of the imported collections.
	Collections []string

	// Records holds the number of imported records per collection name.
	Records map[string]int

	// FailedViews holds the view collections that couldn't be created
	// (usually because their query is not valid Postgres SQL) and their errors.
	FailedViews map[string]error

	// Params is the number of imported _params rows.
	Params int

	// Logs is the number of imported _logs rows.
	Logs int

	// FailedIndexes holds the collection indexes that couldn't be created in
	// Postgres (eg. SQLite specific expressions) and were removed from the collections.
	FailedIndexes map[string][]string

	// FailedRules holds the collection API rules that fail to execute in
	// Postgres (eg. comparisons of incompatible types) and need manual changes.
	FailedRules map[string][]string

	// APIOnlyRules holds the collection API rules that can't be translated
	// to the Postgres RLS policies (they are still enforced by the API).
	APIOnlyRules map[string][]string

	// Storage describes where the records files are.
	Storage string
}

Report describes the result of an import.

func Import

func Import(app core.App, pbDataDir string, opts Options) (*Report, error)

Import copies the collections, records, settings and (optionally) the logs of the PocketBase pb_data directory into the provided bootstrapped popgres app.

The storage files are not copied (see CopyStorage).

func (*Report) HasManualChanges

func (r *Report) HasManualChanges() bool

HasManualChanges reports whether the import found anything that needs manual changes.

func (*Report) String

func (r *Report) String() string

String returns a human readable summary of the report.

Jump to

Keyboard shortcuts

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