schema

package
v0.0.0-...-0f2857b Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

type Column struct {
	Name        string  `json:"name"`
	Type        string  `json:"type"`
	Nullable    bool    `json:"nullable"`
	Default     *string `json:"default,omitempty"`
	IsGenerated bool    `json:"is_generated,omitempty"`
	IsIdentity  bool    `json:"is_identity,omitempty"`
	Comment     string  `json:"comment,omitempty"`
}

type ForeignKey

type ForeignKey struct {
	Table      string   `json:"table"`
	Columns    []string `json:"columns"`
	References []string `json:"references"`
}

type Index

type Index struct {
	Name    string   `json:"name"`
	Columns []string `json:"columns"`
	Unique  bool     `json:"unique"`
	// Method is the access method (btree, gin, hash, ...). Lowercased so
	// values match across Postgres and MySQL (MySQL returns BTREE in
	// upper-case from information_schema.statistics).
	Method string `json:"method,omitempty"`
	// Where holds the partial-index predicate expression for Postgres
	// indexes that have one (e.g., "(deleted_at IS NULL)"). Always empty
	// for MySQL, which has no first-class partial indexes.
	Where string `json:"where,omitempty"`
}

type Introspector

type Introspector interface {
	Introspect(ctx context.Context, db *sql.DB, allowedSchemas []string) (Schema, error)
}

func MySQLIntrospector

func MySQLIntrospector() Introspector

func PostgresIntrospector

func PostgresIntrospector() Introspector

type Schema

type Schema struct {
	Tables []Table `json:"tables"`
}

type Table

type Table struct {
	Schema       string       `json:"schema"`
	Name         string       `json:"name"`
	PrimaryKey   []string     `json:"primary_key"`
	Columns      []Column     `json:"columns"`
	ForeignKeys  []ForeignKey `json:"foreign_keys"`
	ReferencedBy []ForeignKey `json:"referenced_by"`
	Indexes      []Index      `json:"indexes"`
}

Jump to

Keyboard shortcuts

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