schema

package
v0.50.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTableMissing = pkgschema.ErrTableMissing

ErrTableMissing is returned when a table does not exist.

View Source
var Module = fx.Module(
	"vef:schema",
	fx.Provide(
		NewService,
		fx.Annotate(
			NewResource,
			fx.ResultTags(`group:"vef:api:resources"`),
		),
	),
)

Module is the FX module for schema inspection functionality.

Functions

func NewResource

func NewResource(service schema.Service) api.Resource

NewResource creates a new schema inspection resource.

func NewService

func NewService(db *sql.DB, dataSources *config.DataSourcesConfig) (schema.Service, error)

NewService creates a new schema service backed by the primary data source. Multi-data-source schema reflection is intentionally out of scope for v1; callers that need to introspect a non-primary source should inject datasource.Registry, fetch the connection, and drive atlas inspection themselves.

The dialect is validated here but the Atlas inspector is opened on first use, because opening it queries the server. A constructor that dials makes the whole graph unbuildable without a reachable database — which is the same reason the data source module opens without blocking and pings from a start hook, and what lets the API surface be described offline.

Types

type AtlasInspector

type AtlasInspector struct {
	// contains filtered or unexported fields
}

AtlasInspector performs read-only schema inspection backed by Atlas.

func NewInspector

func NewInspector(db *sql.DB, kind config.DBKind, schemaName string) (*AtlasInspector, error)

NewInspector creates a new Atlas Inspector for the given database connection.

func (*AtlasInspector) InspectSchema

func (i *AtlasInspector) InspectSchema(ctx context.Context) (*as.Schema, error)

InspectSchema inspects the current database schema.

func (*AtlasInspector) InspectTable

func (i *AtlasInspector) InspectTable(ctx context.Context, name string) (*as.Table, error)

InspectTable inspects a specific table, returning ErrTableMissing if it does not exist.

func (*AtlasInspector) InspectViews

func (i *AtlasInspector) InspectViews(ctx context.Context) ([]*as.View, error)

InspectViews inspects all views in the current database schema.

type DefaultService

type DefaultService struct {
	// contains filtered or unexported fields
}

DefaultService is the default implementation of schema.Service.

func (*DefaultService) GetTableSchema

func (s *DefaultService) GetTableSchema(ctx context.Context, name string) (*schema.TableSchema, error)

GetTableSchema returns detailed structure information about a specific table.

func (*DefaultService) ListTables

func (s *DefaultService) ListTables(ctx context.Context) ([]schema.Table, error)

ListTables returns all tables in the current database/schema.

func (*DefaultService) ListViews

func (s *DefaultService) ListViews(ctx context.Context) ([]schema.View, error)

ListViews returns all views in the current database/schema.

type GetTableSchemaParams

type GetTableSchemaParams struct {
	api.P

	Name string `json:"name" validate:"required"`
}

GetTableSchemaParams contains parameters for getting table schema details.

type Resource

type Resource struct {
	api.Resource
	// contains filtered or unexported fields
}

Resource handles schema inspection API endpoints.

func (*Resource) GetTableSchema

func (r *Resource) GetTableSchema(ctx fiber.Ctx, params GetTableSchemaParams) error

GetTableSchema returns detailed structure information about a specific table.

func (*Resource) ListTables

func (r *Resource) ListTables(ctx fiber.Ctx) error

ListTables returns all tables in the current database/schema.

func (*Resource) ListViews

func (r *Resource) ListViews(ctx fiber.Ctx) error

ListViews returns all views in the current database/schema.

Jump to

Keyboard shortcuts

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