schemareader

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 28, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VirtualIndexName = "virtual_main_unique_index"
)

Variables

This section is empty.

Functions

func DumpToGraphviz

func DumpToGraphviz(tables map[string]Table)

DumpToGraphviz outputs a dot representation of a schema. Use: go run . | dot -Tx11

func GetConnectionString

func GetConnectionString(configFilePath string) string

GetConnectionString return the connection string for the database after reading config file for

func GetDBconnection

func GetDBconnection(configFilePath string) *sql.DB

GetDBconnection return the database connection

func ReadAllTablesSchema

func ReadAllTablesSchema(db *sql.DB) map[string]Table

ReadTablesSchema inspects the DB and returns a list of tables

func ReadTablesSchema

func ReadTablesSchema(db *sql.DB, tableNames []string) map[string]Table

Types

type Reference

type Reference struct {
	TableName     string
	ColumnMapping map[string]string
}

Reference represents a foreign key relationship to a Table

type Table

type Table struct {
	Name            string
	Export          bool
	Columns         []string
	UnexportColumns map[string]bool
	ColumnIndexes   map[string]int
	PKColumns       map[string]bool
	PKSequence      string
	UniqueIndexes   map[string]UniqueIndex
	// a unique index is main when it is the preferred "natural" key
	MainUniqueIndexName string
	References          []Reference
	ReferencedBy        []Reference
}

Table represents a DB table to dump

func (*Table) GetFirstReferenceFromColumn

func (table *Table) GetFirstReferenceFromColumn(columnName string) Reference

we are returning just one reference, the first one which uses the column we want

type UniqueIndex

type UniqueIndex struct {
	Name    string
	Columns []string
}

UniqueIndex represents an index among columns of a Table

Jump to

Keyboard shortcuts

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