Documentation
¶
Overview ¶
Package fetch queries source database for objects and data
Index ¶
- Variables
- func CollectAndAssociateContext[P associer[C, P], C any](ctx context.Context, n string, parents []P, rowto rowToFunc[C]) ([]P, int, error)
- func CollectMapContext(ctx context.Context, n string) (map[string]any, error)
- func CollectObjectsContext[T any](ctx context.Context, n string, rowto rowToFunc[T]) ([]T, error)
- func CopyTables(p *dispatch.Plan, tables []catalog.Table, srcModel any)
- func CopyTask(source, target catalog.Table, reqs []string) dispatch.Task
- func FilterSchemas(patterns ...string)
- func ForEachContext(ctx context.Context, n string, f func(*sql.Rows) error) (int, error)
- func ForEachItemAssociateContext[P associer[C, P], C any](ctx context.Context, parents []P, query func(P) (string, []any), ...) ([]P, int, error)
- func QueryRowContext(ctx context.Context, n string) *sql.Row
- func Render(name string, o any) string
- func RestartIdentities(tables []catalog.Table) dispatch.Task
- func RestartSequences(seqs []catalog.Sequence) dispatch.Task
- func SQL(name string, fmtArgs ...any) (string, []any)
- func Setup(sqlFiles fs.FS, f func(int) string, funcs template.FuncMap)
- func Value(path, from, to string) valueFactory
Constants ¶
This section is empty.
Variables ¶
var CopyRate = monitoring.NewRate(" rows")
var CopyThroughput = monitoring.NewIRate("B")
var TableCount int
Functions ¶
func CollectAndAssociateContext ¶
func CollectAndAssociateContext[P associer[C, P], C any](ctx context.Context, n string, parents []P, rowto rowToFunc[C]) ([]P, int, error)
CollectAndAssociateContext queries child objects
Returns parents with associated components and the count of components.
If a component does not match an existing parent, skip to next component and search starting from last associated parent. Fails after 8 unassociated components.
Use this to query table columns, keys, etc.
func CollectMapContext ¶
func CollectObjectsContext ¶
CollectObjectsContext accumulates rows
func CopyTables ¶
CopyTables instanciates COPY operations for a list of tables
func CopyTask ¶
CopyTask instanciates a COPY operation for a table
Task weight is source table row count. Generates a COPY statement for each batch of rows. Use SetupExecute to configure query output.
func FilterSchemas ¶
func FilterSchemas(patterns ...string)
FilterSchemas restricts queries to a list of schemas
All subsequent queries must accept a %s fmt parameter for schemas name substitutions. e.g. WHERE OWNER IN (%s)
func ForEachContext ¶
func ForEachItemAssociateContext ¶
func ForEachItemAssociateContext[P associer[C, P], C any](ctx context.Context, parents []P, query func(P) (string, []any), rowto rowToFunc[C]) ([]P, int, error)
ForEachItemAssociateContext execute a query for each item
Use it to inspect extra information for item with per-item query like `SHOW CREATE`.
func QueryRowContext ¶
QueryRowContext executes a query that is expected to return a single row
Panics if connexion to database is not already established.
func RestartIdentities ¶
RestartIdentities fetches identities start from source and generates ALTER COLUMN.
Returns nil if no tables have identity column.
Requires source connection in context from database.WithConnection.
func RestartSequences ¶
RestartSequences fetches sequences start from source and generates ALTER SEQUENCE.
Returns nil if no sequences are given. Group sequence restart by schema.
Requires catalog.FilterSchemas to be set with schemas containing sequences. Requires source connection in context from database.WithConnection.
func SQL ¶
SQL reads embedded query
panics if query is not found
Removes lines ending with `-- pg_migrate:skip` pragma. Uncomment line with `-- pg_migrate:uncomment` pragma. Inject fmtArgs if provided else inject schemas list if FilterSchemas() was called.
Types ¶
This section is empty.