Documentation
¶
Overview ¶
Package service provides application-level operations shared by the CLI and TUI frontends.
Index ¶
- func DumpTable(ctx context.Context, w io.Writer, opts DumpOptions) (output.Result, error)
- func ErrUnsupportedImportFormat(format string) error
- func LoadTable(ctx context.Context, r io.Reader, opts LoadOptions) (db.ImportResult, error)
- type AccessService
- type Column
- type Completion
- type DataEditService
- func (s DataEditService) Delete(ctx context.Context, tableName, whereClause string) (int, error)
- func (s DataEditService) Insert(ctx context.Context, tableName string, values map[string]string) (int, error)
- func (s DataEditService) Update(ctx context.Context, tableName string, values map[string]string, ...) (int, error)
- type DumpOptions
- type ExecOptions
- type Executor
- type Index
- type LoadOptions
- type MetadataService
- func (s MetadataService) Columns(ctx context.Context, tableName string) ([]Column, error)
- func (s MetadataService) Complete(ctx context.Context, prefix, tableName string) ([]Completion, error)
- func (s MetadataService) DDL(ctx context.Context, tableName string) (string, error)
- func (s MetadataService) Indexes(ctx context.Context, tableName string) ([]Index, error)
- func (s MetadataService) MermaidER(ctx context.Context) (string, error)
- func (s MetadataService) Schema(ctx context.Context) (Schema, error)
- func (s MetadataService) Schemas(ctx context.Context) ([]string, error)
- func (s MetadataService) Tables(ctx context.Context) ([]Table, error)
- type MigrationService
- func (s MigrationService) Apply(ctx context.Context, dir string, limit int) (db.MigrationResult, error)
- func (s MigrationService) Baseline(ctx context.Context, dir, version string) (db.MigrationResult, error)
- func (s MigrationService) Plan(ctx context.Context, dir string, rollbackLimit int) (db.MigrationPlan, error)
- func (s MigrationService) Rollback(ctx context.Context, dir string, limit int) (db.MigrationResult, error)
- func (s MigrationService) Status(ctx context.Context, dir string) ([]db.Migration, error)
- type Schema
- type SchemaChange
- type SchemaDiff
- type Table
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrUnsupportedImportFormat ¶
ErrUnsupportedImportFormat formats unsupported table import formats.
func LoadTable ¶
func LoadTable(ctx context.Context, r io.Reader, opts LoadOptions) (db.ImportResult, error)
LoadTable reads rows from r into one database table.
Types ¶
type AccessService ¶
AccessService reads database role and grant metadata.
type Column ¶
type Column struct {
Name string `json:"name"`
Type string `json:"type"`
Nullable bool `json:"nullable"`
Primary bool `json:"primary"`
Unique bool `json:"unique,omitempty"`
Default string `json:"default,omitempty"`
References string `json:"references,omitempty"`
}
Column describes one table column and common relational constraints.
type Completion ¶
type Completion struct {
Value string `json:"value"`
Kind string `json:"kind"`
Table string `json:"table,omitempty"`
}
Completion describes one SQL completion candidate.
type DataEditService ¶
DataEditService performs row-level table edits.
type DumpOptions ¶
DumpOptions controls table export.
type ExecOptions ¶
type ExecOptions struct {
Format string
MaxRows int
Driver string
DSN string
Explain bool
Analyze bool
Transaction bool
}
ExecOptions carries execution settings from the presentation layer into the service and database layers.
type Executor ¶
type Executor struct{}
Executor executes SQL through the configured database backend.
type Index ¶
type Index struct {
Name string `json:"name"`
Columns []string `json:"columns"`
Unique bool `json:"unique"`
Primary bool `json:"primary,omitempty"`
}
Index describes one table index.
type LoadOptions ¶
LoadOptions controls table import.
type MetadataService ¶
type MetadataService struct {
// contains filtered or unexported fields
}
MetadataService serves schema metadata from either a live database or an in-memory fallback schema.
func NewConnectedMetadataService ¶
func NewConnectedMetadataService(driver, dsn string) MetadataService
NewConnectedMetadataService returns a metadata service backed by a live database connection.
func NewConnectedMetadataServiceWithSchema ¶
func NewConnectedMetadataServiceWithSchema(driver, dsn, schemaName string) MetadataService
NewConnectedMetadataServiceWithSchema returns a metadata service backed by a live database connection and constrained to schemaName when supported.
func NewMetadataService ¶
func NewMetadataService() MetadataService
NewMetadataService returns an in-memory metadata service used when no live database connection is configured.
func (MetadataService) Complete ¶
func (s MetadataService) Complete(ctx context.Context, prefix, tableName string) ([]Completion, error)
Complete returns keyword, table, and column candidates matching prefix.
func (MetadataService) DDL ¶
DDL returns a CREATE TABLE statement for tableName when metadata is available.
func (MetadataService) MermaidER ¶
func (s MetadataService) MermaidER(ctx context.Context) (string, error)
MermaidER renders the schema as a Mermaid ER diagram.
func (MetadataService) Schema ¶
func (s MetadataService) Schema(ctx context.Context) (Schema, error)
Schema returns the complete schema for the configured metadata source.
type MigrationService ¶
MigrationService applies and inspects SQL migrations.
func (MigrationService) Apply ¶
func (s MigrationService) Apply(ctx context.Context, dir string, limit int) (db.MigrationResult, error)
func (MigrationService) Baseline ¶
func (s MigrationService) Baseline(ctx context.Context, dir, version string) (db.MigrationResult, error)
func (MigrationService) Plan ¶
func (s MigrationService) Plan(ctx context.Context, dir string, rollbackLimit int) (db.MigrationPlan, error)
func (MigrationService) Rollback ¶
func (s MigrationService) Rollback(ctx context.Context, dir string, limit int) (db.MigrationResult, error)
type SchemaChange ¶
type SchemaChange struct {
Type string `json:"type"`
Table string `json:"table"`
Name string `json:"name,omitempty"`
Detail string `json:"detail,omitempty"`
}
SchemaChange describes one schema difference.
type SchemaDiff ¶
type SchemaDiff struct {
Changes []SchemaChange `json:"changes"`
}
SchemaDiff contains human-readable schema differences.
func DiffSchemas ¶
func DiffSchemas(from, to Schema) SchemaDiff
DiffSchemas compares two schema snapshots and reports table, column, and index additions/removals.