schema

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTableNotFound = errors.New("table not found")

ErrTableNotFound is returned when a table does not exist.

View Source
var ErrUnsupportedDbType = errors.New("unsupported database type")
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, dsConfig *config.DatasourceConfig) (schema.Service, error)

NewService creates a new schema service.

Types

type AtlasInspector

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

func (*AtlasInspector) InspectSchema

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

func (*AtlasInspector) InspectTable

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

func (*AtlasInspector) InspectTriggers

func (i *AtlasInspector) InspectTriggers(ctx context.Context) ([]*as.Trigger, error)

func (*AtlasInspector) InspectViews

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

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) ListTriggers

func (s *DefaultService) ListTriggers(ctx context.Context) ([]schema.Trigger, error)

ListTriggers returns all triggers 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 Inspector

type Inspector interface {
	// InspectSchema inspects the current database schema.
	InspectSchema(ctx context.Context) (*as.Schema, error)
	// InspectTable inspects a specific table.
	InspectTable(ctx context.Context, name string) (*as.Table, error)
	// InspectViews inspects all views in the current database schema.
	InspectViews(ctx context.Context) ([]*as.View, error)
	// InspectTriggers inspects all triggers in the current database schema.
	InspectTriggers(ctx context.Context) ([]*as.Trigger, error)
}

Inspector wraps Atlas inspection capabilities for read-only schema inspection.

func NewInspector

func NewInspector(db *sql.DB, dbType constants.DbType, schemaName string) (Inspector, error)

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

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) ListTriggers

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

ListTriggers returns all triggers 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