Documentation
¶
Index ¶
- Constants
- func DumpToGraphviz(tables map[string]Table)
- func GetConnectionString(configFilePath string) string
- func GetDBconnection(configFilePath string) *sql.DB
- func ReadAllTablesSchema(db *sql.DB) map[string]Table
- func ReadTablesSchema(db *sql.DB, tableNames []string) map[string]Table
- type Reference
- type Table
- type UniqueIndex
Constants ¶
View Source
const ( ReadTableNames = `SELECT table_name FROM information_schema.tables WHERE table_schema = 'public' AND table_type = 'BASE TABLE';` ReadColumnNames = `` /* 133-byte string literal not displayed */ ReadPkColumnNames = `` /* 175-byte string literal not displayed */ ReadUniqueIndexNames = `` /* 213-byte string literal not displayed */ ReadIndexColumns = `` /* 169-byte string literal not displayed */ ReadReferenceConstraintNames = `` /* 296-byte string literal not displayed */ ReadReferencedByConstraintNames = `` /* 297-byte string literal not displayed */ ReadReferencedTable = `SELECT DISTINCT ccu.table_name FROM information_schema.constraint_column_usage AS ccu WHERE ccu.constraint_name = $1;` ReadReferencedByTable = `SELECT DISTINCT table_name FROM information_schema.table_constraints as tc WHERE tc.constraint_name = $1;` ReadReferenceConstraints = `` /* 539-byte string literal not displayed */ ReadPkSequence = `` /* 754-byte string literal not displayed */ )
View Source
const (
VirtualIndexName = "virtual_main_unique_index"
)
Variables ¶
This section is empty.
Functions ¶
func DumpToGraphviz ¶
DumpToGraphviz outputs a dot representation of a schema. Use: go run . | dot -Tx11
func GetConnectionString ¶
GetConnectionString return the connection string for the database after reading config file for
func GetDBconnection ¶
GetDBconnection return the database connection
func ReadAllTablesSchema ¶
ReadTablesSchema inspects the DB and returns a list of tables
Types ¶
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 ¶
we are returning just one reference, the first one which uses the column we want
type UniqueIndex ¶
UniqueIndex represents an index among columns of a Table
Click to show internal directories.
Click to hide internal directories.