On this page
Package parse provides a lenient TOML parser for pgdesign schema files, extracting structure without enforcing semantic rules into a RawSchema.
#internal/parse
#internal/parse
Package parse turns pgdesign schema TOML into a RawSchema. Entry points (File/Bytes/Files/Dir) first run a strictspec-generated document-shape gate (see gate.go and pgschema/): strictspec is the single authority for shape — well-formedness, closed records (unknown keys), base-type conformance, required fields, and the identifier/pgtype/sql-expression custom-scalar lexemes. Only shape-valid documents are walked into a RawSchema; semantic rules (type existence, reference/enum-value resolution, SQL grammaticality, normal form) remain native in model/validate. Every schema document must carry a top-level format_version.
Column order is preserved via AST walking (not map iteration).
#RawSchema
type RawSchema structRawSchema is the top-level result of parsing one or more TOML schema files.
#RawMeta
type RawMeta structRawMeta holds the [meta] section values.
#RawSMState
type RawSMState structRawSMState holds a state in a state machine type from [types..states.].
#RawSMTransition
type RawSMTransition structRawSMTransition holds a transition in a state machine type from [[types.*.transitions]].
#RawCompositeField
type RawCompositeField structRawCompositeField holds one composite type field from [types.*.fields].
#RawType
type RawType structRawType holds a user-defined type from [types.*].
#RawView
type RawView structRawView holds a view definition from [views.*].
#RawMaterializedView
type RawMaterializedView structRawMaterializedView holds a materialized view definition from [materialized_views.*].
#RawSequence
type RawSequence structRawSequence holds a sequence definition from [sequences.*].
#RawTable
type RawTable structRawTable holds a table definition from [tables.*].
#RawColumn
type RawColumn structRawColumn holds a column definition from [tables..columns.].
#RawFK
type RawFK structRawFK holds a foreign key constraint from [tables..fks.].
#RawIndex
type RawIndex structRawIndex holds an index definition from [tables..indexes.].
#RawUnique
type RawUnique structRawUnique holds a unique constraint from [tables..unique.].
#RawCheck
type RawCheck structRawCheck holds a check constraint from [tables..checks.].
#RawExclusion
type RawExclusion structRawExclusion holds an exclusion constraint from [tables..exclusions.].
#RawPolicy
type RawPolicy structRawPolicy holds a row-level security policy from [tables..policies.].
#RawTrigger
type RawTrigger structRawTrigger holds a trigger definition from [tables..triggers.].
#RawPartitioning
type RawPartitioning structRawPartitioning holds partition configuration from [tables.*.partitioning].
#RawDependency
type RawDependency structRawDependency holds a functional dependency from [[tables.*.dependencies]].
#RawMaintenance
type RawMaintenance structRawMaintenance holds maintenance configuration from [tables.*.maintenance].
#RawFunctionArg
type RawFunctionArg structRawFunctionArg holds a function argument from [[functions.*.args]].
#RawFunction
type RawFunction structRawFunction holds a function or procedure definition from [functions.*].
#CollectUserTypes
func CollectUserTypes(raw *RawSchema) []semtype.UserTypeDefCollectUserTypes converts a RawSchema's user-defined types into UserTypeDefs suitable for loading into a semtype.Registry. This is the single canonical conversion point — all callers should use this instead of inline conversion.
#File
func File(path string) (*RawSchema, []diagnostic.Diagnostic)File parses a single TOML schema file and returns a RawSchema with diagnostics. It continues past errors, returning partial results even on failure.
#Bytes
func Bytes(data []byte) (*RawSchema, []diagnostic.Diagnostic)Bytes parses TOML bytes and returns a RawSchema with diagnostics. Like File but operates on in-memory bytes instead of reading from disk.
#Files
func Files(paths []string) ([]*RawSchema, []diagnostic.Diagnostic)Files parses multiple TOML schema files and returns all schemas with aggregated diagnostics.
#Dir
func Dir(dirPath string) ([]*RawSchema, []diagnostic.Diagnostic)Dir finds all .toml schema files in a directory (excluding pgdesign.toml), parses each, and returns all schemas with aggregated diagnostics.