introspect

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: May 31, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package introspect implements the `gco introspect` command for generating schema files from an existing database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectProvider

func DetectProvider(dsn string) string

DetectProvider infers the database provider from a connection string.

func GenerateSchema

func GenerateSchema(provider string, tables []TableInfo) string

GenerateSchema produces .gcorm schema text from introspected table info.

func Run

func Run(args []string) error

Run executes the introspect command.

func WriteSchemaFile

func WriteSchemaFile(dir, filename, content string) error

WriteSchemaFile writes generated schema to a file.

Types

type ColumnInfo

type ColumnInfo struct {
	Name         string
	DataType     string
	IsNullable   bool
	IsPrimaryKey bool
	IsUnique     bool
	Default      string
	Comment      string
}

ColumnInfo describes a single database column.

type ForeignKeyInfo

type ForeignKeyInfo struct {
	Name       string
	Columns    []string
	RefTable   string
	RefColumns []string
	OnDelete   string
	OnUpdate   string
}

ForeignKeyInfo describes a foreign key relationship.

type IndexInfo

type IndexInfo struct {
	Name     string
	Columns  []string
	IsUnique bool
}

IndexInfo describes a database index.

type TableInfo

type TableInfo struct {
	Name    string
	Schema  string // database schema/namespace
	Columns []ColumnInfo
	Indexes []IndexInfo
	FKs     []ForeignKeyInfo
}

TableInfo represents a database table discovered during introspection.

Jump to

Keyboard shortcuts

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