Documentation
¶
Index ¶
Constants ¶
const DefaultFilename = "pathsqlx.yml"
DefaultFilename is the default metadata file that pathsqlx looks for.
Variables ¶
This section is empty.
Functions ¶
func AnalyzeAndSave ¶
AnalyzeAndSave is a convenience function that analyzes a database and writes the result to the given path (or DefaultFilename if path is empty).
func ParseForeignKeyDef ¶
ParseForeignKeyDef splits "table.column" into table and column.
Types ¶
type ForeignKey ¶
ForeignKey represents a foreign key relationship between two tables.
type ForeignKeyDef ¶
ForeignKeyDef describes a foreign key relationship using "table.column" notation.
type MetadataReader ¶
type MetadataReader interface {
GetTableMetadata(tableName string) (*TableMetadata, error)
GetForeignKeys(tableName string) ([]ForeignKey, error)
GetAllForeignKeys() ([]ForeignKey, error)
InvalidateCache()
}
MetadataReader is the interface for reading database metadata.
func NewLiveReader ¶
func NewLiveReader(db *sql.DB, driverName string) MetadataReader
NewLiveReader creates a MetadataReader that queries the database at runtime. Supported drivers: "mysql", "postgres", "sqlite3".
type Schema ¶
type Schema struct {
Tables map[string]Table `yaml:"tables"`
ForeignKeys []ForeignKeyDef `yaml:"foreign_keys"`
Paths map[string]string `yaml:"paths,omitempty"`
}
Schema is the top-level structure of a pathsqlx metadata file.
func Analyze ¶
Analyze connects to a database and extracts the full schema metadata. Supported drivers: "mysql", "postgres", "sqlite3".
func LoadDefault ¶
LoadDefault tries to load the default metadata file (pathsqlx.yml) from the current working directory. Returns nil, nil if the file does not exist.
func Parse ¶
Parse parses raw YAML bytes into a Schema. This is a minimal parser that handles the specific structure of pathsqlx metadata files without requiring a third-party YAML library.
func (*Schema) Marshal ¶
Marshal serializes the schema to YAML. We produce hand-formatted YAML for maximum readability rather than relying on a YAML library.
func (*Schema) NewMetadataReader ¶
func (s *Schema) NewMetadataReader() MetadataReader
NewMetadataReader creates a MetadataReader backed by a Schema loaded from a file. This lets the path inference engine work without a live database connection.
type TableMetadata ¶
type TableMetadata struct {
Name string
Columns []string
PrimaryKeys []string
ForeignKeys []ForeignKey
}
TableMetadata represents metadata for a database table.