reverse

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitAdapterSelector

func InitAdapterSelector(newMysqlReverser, newPostgresReverser AdapterBuilder) func(dia string) (adapter Adapter, err error)

func InitHasTable

func InitHasTable(listTables func() ([]string, error)) func(table string) (bool, error)

Types

type Adapter

type Adapter interface {
	ListTables() ([]string, error)

	// ListColumns returns a []string of column names for the given table
	// It MUST NOT return any columns which are foreign key columns. These will instead come from ListReferences
	ListColumns(table string) ([]string, error)

	// ListIndices returns a []string of index names for the given table.
	// It MUST NOT return information referring to PrimaryKey or Foreign Keys, which will instead come from GetColumn and
	// ListReferences respectively
	ListIndices(table string) ([]string, error)

	// ListReferences returns a []string of tables referenced from the given table.
	ListReferences(table string) ([]string, error)

	// GetColumn returns a schema.Column representing the given tableName and colName.
	GetColumn(table, column string) (schema.Column, error)

	// GetIndex returns a schema.Index representing the given tableName and indexName.
	GetIndex(table, column string) (schema.Index, error)

	// GetReference returns a schema.Reference representing the given tableName and indexName.
	GetReference(table, column string) (schema.Reference, error)
}

Adapter is the yoyo interface for reverse-engineering databases to a schema.Database for creating diff migrations and for creating a yoyo.yml from an existing database.

type AdapterBuilder

type AdapterBuilder func(host, userName, dbName, password, port string) (Adapter, error)

type AdapterLoader

type AdapterLoader func(dia string) (adapter Adapter, err error)

type DatabaseReader

type DatabaseReader func(config yoyo.Config) (db schema.Database, err error)

func InitDatabaseReader

func InitDatabaseReader(loadAdapter AdapterLoader) DatabaseReader

ReadDatabase uses the given Adapter to scan and write the database into a schema.Database

type TableSearcher

type TableSearcher func(table, x string) bool

func InitHasColumn

func InitHasColumn(getColumn func(table, column string) (schema.Column, error)) TableSearcher

func InitHasIndex

func InitHasIndex(getIndex func(table, column string) (schema.Index, error)) TableSearcher

func InitHasReference

func InitHasReference(getReference func(table, reference string) (schema.Reference, error)) TableSearcher

Jump to

Keyboard shortcuts

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