migrate

package
v0.0.0-...-c407d37 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 21 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrWait is an error when waiting for input
	ErrWait = errors.New("wait for input")
	// ErrClosed is an error when buffer is closed for writing
	ErrClosed = errors.New("buffer is closed for writing")
)

Functions

func Exec

func Exec(inputReader io.Reader, tx *pop.Connection, wait time.Duration, logger *zap.Logger) error

Exec executes a query

func ReadInSQLLine

func ReadInSQLLine(line string, dropComments bool, dropSearchPath bool) string

ReadInSQLLine reads the SQL line from a string and returns the line as modified by the configuration If dropComments is true, then drops all line comments. If dropSearchPath is true, then drops all search paths.

func SplitStatements

func SplitStatements(lines chan string, statements chan string, wait time.Duration, logger *zap.Logger)

SplitStatements splits a string of SQL statements into a slice with each element being a statement.

Types

type Buffer

type Buffer struct {
	*sync.RWMutex
	// contains filtered or unexported fields
}

Buffer is a wrapper around strings.Builder for concurrent loading and reading.

func NewBuffer

func NewBuffer() *Buffer

NewBuffer returns a new Buffer.

func (*Buffer) Close

func (b *Buffer) Close()

Close closes the buffer for writing

func (*Buffer) Closed

func (b *Buffer) Closed() bool

Closed returns the state of writing on the buffer

func (*Buffer) Index

func (b *Buffer) Index(i int) (byte, error)

Index returns the character at the indexed position in the String

func (*Buffer) Len

func (b *Buffer) Len() int

Len returns the length of the buffer

func (*Buffer) Range

func (b *Buffer) Range(start int, end int) (string, error)

Range returns a string from a range within the buffer

func (*Buffer) String

func (b *Buffer) String() string

String returns

func (*Buffer) WriteByte

func (b *Buffer) WriteByte(x byte) error

WriteByte writes a byte to the buffer

func (*Buffer) WriteRune

func (b *Buffer) WriteRune(x rune) (int, error)

WriteRune writes a rune to the buffer

func (*Buffer) WriteString

func (b *Buffer) WriteString(x string) (int, error)

WriteString writes a string to the buffer

type Builder

type Builder struct {
	*pop.Match
	Path string
}

Builder is a builder for pop migrations.

func (*Builder) Compile

func (b *Builder) Compile(s3Client S3GetObjectAPI, wait time.Duration, logger *zap.Logger) (*pop.Migration, error)

Compile compiles the provided configration into a migration.

type ErrInvalidDirection

type ErrInvalidDirection struct {
	Value string
}

ErrInvalidDirection is an error for an invalid direction

func (*ErrInvalidDirection) Error

func (e *ErrInvalidDirection) Error() string

type ErrInvalidFormat

type ErrInvalidFormat struct {
	Value string
}

ErrInvalidFormat is an error for an invalid migration format. Only SQL and Fizz are currently supported

func (*ErrInvalidFormat) Error

func (e *ErrInvalidFormat) Error() string

type ErrInvalidPath

type ErrInvalidPath struct {
	Value string
}

ErrInvalidPath is an error for an invalid path

func (*ErrInvalidPath) Error

func (e *ErrInvalidPath) Error() string

type FileHelper

type FileHelper struct {
	// contains filtered or unexported fields
}

FileHelper is an afero filesystem struct

func NewFileHelper

func NewFileHelper() *FileHelper

NewFileHelper creates and returns a new File Helper

func (*FileHelper) ListFiles

func (fh *FileHelper) ListFiles(p string, s3Client S3ListObjectsV2API) ([]string, error)

ListFiles lists the files in a given directory.

func (*FileHelper) SetFileSystem

func (fh *FileHelper) SetFileSystem(fs afero.Fs)

SetFileSystem sets the file system for the file helper

type S3GetObjectAPI

type S3GetObjectAPI interface {
	GetObject(ctx context.Context, params *s3.GetObjectInput, optFns ...func(*s3.Options)) (*s3.GetObjectOutput, error)
}

type S3ListObjectsV2API

type S3ListObjectsV2API interface {
	ListObjectsV2(ctx context.Context, params *s3.ListObjectsV2Input, optFns ...func(*s3.Options)) (*s3.ListObjectsV2Output, error)
}

type Stack

type Stack struct {
	// contains filtered or unexported fields
}

Stack represents a collection of SQL queries

func NewStack

func NewStack() Stack

NewStack creates a new Stack with an empty slice of strings for queries

func (*Stack) Empty

func (s *Stack) Empty() bool

Empty returns true if the stack has no queries in it

func (*Stack) Last

func (s *Stack) Last() string

Last returns the last query from the stack

func (*Stack) Len

func (s *Stack) Len() int

Len returns the list of queries in the stack

func (*Stack) Pop

func (s *Stack) Pop()

Pop removes the last item from the stack

func (*Stack) Push

func (s *Stack) Push(str string)

Push appends a query to the Stack

func (*Stack) Slice

func (s *Stack) Slice() []string

Slice returns the slice of strings from the Stack

Jump to

Keyboard shortcuts

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