schema

package
v0.6.7 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: AGPL-3.0 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
	Type    string
	NotNull bool
	Default string
	PK      int
}

type ForeignKey

type ForeignKey struct {
	From  string // column in this table
	Table string // referenced table
	To    string // referenced column
}

ForeignKey describes a single-column relationship from this table to another.

type Index

type Index struct {
	Name   string
	Table  string
	Unique bool
	SQL    string
}

type Schema

type Schema struct {
	Tables []Table
}

func FromSQL

func FromSQL(sqlText string) (*Schema, error)

FromSQL materializes a declarative schema (a body of CREATE statements) into a throwaway database and returns the resulting Schema. This lets a checked-in schema.sql be compared against a live database with the normal diff engine.

func Load

func Load(path string) (*Schema, error)

func (*Schema) Mermaid

func (s *Schema) Mermaid() string

Mermaid renders the schema as a Mermaid erDiagram, suitable for pasting into a README or any Mermaid-aware renderer. Foreign keys become relationships.

func (*Schema) String

func (s *Schema) String() string

func (*Schema) TableMap

func (s *Schema) TableMap() map[string]Table

type Table

type Table struct {
	Name        string
	Columns     []Column
	Indexes     []Index
	ForeignKeys []ForeignKey
}

Jump to

Keyboard shortcuts

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