schema

package
v1.4.8-beta Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterExcluded added in v1.4.1

func FilterExcluded(tables, exclude []string) []string

FilterExcluded returns tables with any in the exclude list removed.

func GetDefaultCachePath

func GetDefaultCachePath(baseDir string) string

GetDefaultCachePath returns the default path for schema cache

Types

type AutoDiscoverer added in v1.4.1

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

AutoDiscoverer implements Discoverer by querying the live database

func NewAutoDiscoverer added in v1.4.1

func NewAutoDiscoverer(db *sql.DB, dbType string, excludeTables []string) *AutoDiscoverer

NewAutoDiscoverer creates an AutoDiscoverer backed by an open database connection. The caller is responsible for closing the db when done.

func (*AutoDiscoverer) DiscoverTables added in v1.4.1

func (a *AutoDiscoverer) DiscoverTables() ([]string, error)

DiscoverTables queries the database for all user tables and returns their names, excluding any in the ExcludeTables list.

func (*AutoDiscoverer) GetTableColumns added in v1.4.1

func (a *AutoDiscoverer) GetTableColumns(table string) ([]ColumnInfo, error)

GetTableColumns returns column metadata for the given table.

func (*AutoDiscoverer) LoadCache added in v1.4.1

func (a *AutoDiscoverer) LoadCache(cacheFile string) error

func (*AutoDiscoverer) SaveCache added in v1.4.1

func (a *AutoDiscoverer) SaveCache(cacheFile string) error

type ColumnInfo

type ColumnInfo struct {
	Name      string `json:"name"`
	Type      string `json:"type"`
	Nullable  bool   `json:"nullable"`
	IsPrimary bool   `json:"is_primary"`
	Default   string `json:"default,omitempty"`
}

ColumnInfo represents column metadata

type Discoverer

type Discoverer interface {
	DiscoverTables() ([]string, error)
	GetTableColumns(table string) ([]ColumnInfo, error)
	SaveCache(cacheFile string) error
	LoadCache(cacheFile string) error
}

Discoverer defines the interface for schema discovery

func CreateDiscoverer

func CreateDiscoverer(mode string, staticTables []string, excludeTables []string, dbType string, db *sql.DB) (Discoverer, error)

CreateDiscoverer creates a discoverer based on mode and configuration. For "auto" mode, db must be an open database connection; the caller is responsible for closing it.

type NoOpDiscoverer

type NoOpDiscoverer struct{}

NoOpDiscoverer implements Discoverer for when discovery is disabled

func NewNoOpDiscoverer

func NewNoOpDiscoverer() *NoOpDiscoverer

func (*NoOpDiscoverer) DiscoverTables

func (n *NoOpDiscoverer) DiscoverTables() ([]string, error)

func (*NoOpDiscoverer) GetTableColumns

func (n *NoOpDiscoverer) GetTableColumns(table string) ([]ColumnInfo, error)

func (*NoOpDiscoverer) LoadCache

func (n *NoOpDiscoverer) LoadCache(cacheFile string) error

func (*NoOpDiscoverer) SaveCache

func (n *NoOpDiscoverer) SaveCache(cacheFile string) error

type SchemaCache

type SchemaCache struct {
	Tables  map[string][]ColumnInfo `json:"tables"`
	Version string                  `json:"version"`
}

SchemaCache represents cached schema information

type StaticDiscoverer

type StaticDiscoverer struct {
	Tables     []string
	ColumnInfo map[string][]ColumnInfo
}

StaticDiscoverer implements Discoverer for static table lists

func NewStaticDiscoverer

func NewStaticDiscoverer(tables []string) *StaticDiscoverer

func (*StaticDiscoverer) DiscoverTables

func (s *StaticDiscoverer) DiscoverTables() ([]string, error)

func (*StaticDiscoverer) GetTableColumns

func (s *StaticDiscoverer) GetTableColumns(table string) ([]ColumnInfo, error)

func (*StaticDiscoverer) LoadCache

func (s *StaticDiscoverer) LoadCache(cacheFile string) error

func (*StaticDiscoverer) SaveCache

func (s *StaticDiscoverer) SaveCache(cacheFile string) error

func (*StaticDiscoverer) SetTableColumns

func (s *StaticDiscoverer) SetTableColumns(table string, columns []ColumnInfo)

Jump to

Keyboard shortcuts

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