preset

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package preset knows the schemas of common platforms: where they keep personal data, how their tables link up, and which settings would let a staging copy act on real customers.

Index

Constants

This section is empty.

Variables

View Source
var Names = []string{"wordpress", "woocommerce", "magento2", "laravel"}

Names lists the presets that can be asked for by name.

Functions

func Safe

func Safe(s string) string

Safe returns s if it looks like an identifier (a hook, job or gateway name) and a placeholder otherwise, so no stored value can slip into a report through a label.

Types

type MetaTable

type MetaTable struct {
	Key, Value string
	Platform   string
	Keys       map[string]*detect.Hint       // known keys
	Probe      []string                      // keys worth reading directly if the sample misses them
	HintFor    func(key string) *detect.Hint // pattern-based hints
	Label      func(key string) string       // maps raw keys to names, e.g. Magento attribute IDs
}

MetaTable describes a key/value table such as wp_postmeta. Each key is judged on its own, as if it were a column.

func (*MetaTable) Hint

func (m *MetaTable) Hint(key string) *detect.Hint

Hint returns what the preset knows about one key.

type Querier

type Querier interface {
	QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
	QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
}

Querier is the part of *sql.DB the presets need.

type Result

type Result struct {
	Platforms     []model.Platform
	Columns       map[string]map[string]*detect.Hint // table → lower-case column → hint
	Meta          map[string]*MetaTable
	Actions       map[string]TableAction
	Relationships []model.Relationship
	Prefixes      []string
	SideEffects   []model.SideEffect
	Warnings      []string
}

Result is everything the presets found.

func Detect

func Detect(ctx context.Context, q Querier, schema *model.Schema, which string, timeout time.Duration) *Result

Detect recognises platforms and collects their hints and side effects. which is "auto", "none" or one of Names.

func (*Result) ColumnHint

func (r *Result) ColumnHint(table, column string) *detect.Hint

ColumnHint returns the preset hint for a column, if any.

type TableAction

type TableAction struct {
	Action string // "truncate"
	Reason string
}

TableAction is advice for a whole table, e.g. to empty it in the copy.

Jump to

Keyboard shortcuts

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