mirror of
https://github.com/hanzoai/o11y.git
synced 2026-10-15 12:58:33 +00:00
Full rebrand of the SigNoz observability platform: - Go module: github.com/SigNoz/signoz → github.com/hanzoai/o11y - Frontend: @signozhq/* → @hanzo/o11y-*, posthog-js → @hanzo/insights - Docker: signoz/* → ghcr.io/hanzoai/o11y* - ClickHouse → Hanzo Datastore (hanzoai/datastore) - Env vars: SIGNOZ_* → HANZO_* - DB tables: signoz_* → o11y_* - All branding, URLs, docs updated - 2172 files changed
59 lines
1.7 KiB
Go
59 lines
1.7 KiB
Go
package sqlschematest
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/hanzoai/o11y/pkg/errors"
|
|
"github.com/hanzoai/o11y/pkg/sqlschema"
|
|
"github.com/uptrace/bun"
|
|
"github.com/uptrace/bun/schema"
|
|
)
|
|
|
|
var _ sqlschema.SQLSchema = (*Provider)(nil)
|
|
|
|
type Provider struct {
|
|
Fmter sqlschema.Formatter
|
|
Tables map[string]*sqlschema.Table
|
|
UniqueConstraints map[string][]*sqlschema.UniqueConstraint
|
|
Indices map[string]sqlschema.Index
|
|
}
|
|
|
|
func New(tables map[string]*sqlschema.Table, uniqueConstraints map[string][]*sqlschema.UniqueConstraint, indices map[string]sqlschema.Index) *Provider {
|
|
return &Provider{
|
|
Fmter: sqlschema.NewFormatter(schema.NewNopFormatter().Dialect()),
|
|
Tables: tables,
|
|
UniqueConstraints: uniqueConstraints,
|
|
Indices: indices,
|
|
}
|
|
}
|
|
|
|
func (provider *Provider) Formatter() sqlschema.SQLFormatter {
|
|
return provider.Fmter
|
|
}
|
|
|
|
func (provider *Provider) Operator() sqlschema.SQLOperator {
|
|
return sqlschema.NewOperator(provider.Fmter, sqlschema.OperatorSupport{})
|
|
}
|
|
|
|
func (provider *Provider) GetTable(ctx context.Context, name sqlschema.TableName) (*sqlschema.Table, []*sqlschema.UniqueConstraint, error) {
|
|
table, ok := provider.Tables[string(name)]
|
|
if !ok {
|
|
return nil, nil, errors.NewNotFoundf(errors.CodeNotFound, "table %s not found", name)
|
|
}
|
|
|
|
return table, provider.UniqueConstraints[string(name)], nil
|
|
}
|
|
|
|
func (provider *Provider) GetIndices(ctx context.Context, name sqlschema.TableName) ([]sqlschema.Index, error) {
|
|
indices, ok := provider.Indices[string(name)]
|
|
if !ok {
|
|
return []sqlschema.Index{}, nil
|
|
}
|
|
|
|
return []sqlschema.Index{indices}, nil
|
|
}
|
|
|
|
func (provider *Provider) ToggleFKEnforcement(_ context.Context, _ bun.IDB, _ bool) error {
|
|
return nil
|
|
}
|