dumper

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package dumper handles writing SQL statements, obtained from objects in a live schema, to files in a directory. It can be used to do an initial dump, to update a previous dump to reflect changes in a schema, or to reformat statements to match canonical formats.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddDelimiter

func AddDelimiter(key tengo.ObjectKey, statementBody, oldEnding string) string

AddDelimiter takes the supplied string and appends a delimiter to the end. If the supplied string is a multi-statement routine, delimiter commands will be prepended and appended to the string appropriately.

func DumpSchema

func DumpSchema(schema *tengo.Schema, dir *fs.Dir, opts Options) (int, error)

DumpSchema updates the *.sql files in dir to match the creation statements in schema. Any preexisting creation statements in the dir will be updated to match the canonical format from the live schema. Objects that no longer exist in the live schema will have their statements removed. A count of modified files is returned, along with any fatal write error. If opts.CountOnly is true, no actual filesystem writes occur, but a file count is still returned.

Types

type Options

type Options struct {
	IncludeAutoInc bool                   // if false, strip AUTO_INCREMENT clauses from CREATE TABLE
	Partitioning   tengo.PartitioningMode // PartitioningKeep: retain previous FS partitioning clause; PartitioningRemove: strip partitioning clause
	CountOnly      bool                   // if true, skip writing files, just report count of rewrites
	IgnoreTable    *regexp.Regexp         // skip tables with names matching this regex
	// contains filtered or unexported fields
}

Options controls dumper behavior.

func (*Options) IgnoreKeys

func (opts *Options) IgnoreKeys(keys []tengo.ObjectKey)

IgnoreKeys specifies a list of tengo.ObjectKeys that the dump should ignore. Repeated calls to this method add to the existing list of ignored keys. If the same key was supplied to both OnlyKeys and IgnoreKeys, the latter takes precedence, meaning the object will be skipped.

func (*Options) OnlyKeys

func (opts *Options) OnlyKeys(keys []tengo.ObjectKey)

OnlyKeys specifies a list of tengo.ObjectKeys that the dump should operate on. (Objects with keys NOT in this list will be skipped.) Repeated calls to this method add to the existing allowlist.

Jump to

Keyboard shortcuts

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