schema

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VolatilityImmutable = "IMMUTABLE"
	VolatilityStable    = "STABLE"
	VolatilityVolatile  = "VOLATILE"
)
View Source
const (
	IndexTypeBTree  = "btree"
	IndexTypeHash   = "hash"
	IndexTypeGIN    = "gin"
	IndexTypeGiST   = "gist"
	IndexTypeSPGiST = "spgist"
	IndexTypeBRIN   = "brin"
)
View Source
const (
	DefaultSchema = "public"
	SchemaVersion = "1.0"

	ForeignKey = "FOREIGN KEY"
	NoAction   = "NO ACTION"
)
View Source
const (
	ConstraintPrimaryKey = "PRIMARY KEY"
	ConstraintForeignKey = "FOREIGN KEY"
	ConstraintUnique     = "UNIQUE"
	ConstraintCheck      = "CHECK"
	ConstraintExclude    = "EXCLUDE"
)

Variables

This section is empty.

Functions

func NormalizeIdentifier

func NormalizeIdentifier(identifier string) string

func NormalizeSchemaName

func NormalizeSchemaName(schema string) string

func QualifiedName

func QualifiedName(schema, name string) string

Types

type Column

type Column struct {
	Name     string `json:"name"`
	DataType string `json:"data_type"`
	Position int    `json:"position"`

	IsNullable bool   `json:"is_nullable"`
	Default    string `json:"default,omitempty"`
	Comment    string `json:"comment,omitempty"`

	MaxLength *int `json:"max_length,omitempty"`
	Precision *int `json:"precision,omitempty"`
	Scale     *int `json:"scale,omitempty"`

	IsArray              bool   `json:"is_array,omitempty"`
	IsIdentity           bool   `json:"is_identity,omitempty"`
	IdentityGeneration   string `json:"identity_generation,omitempty"`
	IsGenerated          bool   `json:"is_generated,omitempty"`
	GenerationExpression string `json:"generation_expression,omitempty"`
}

func (*Column) FullDataType

func (c *Column) FullDataType() string

func (*Column) IsPrimaryKey

func (c *Column) IsPrimaryKey(table *Table) bool

type CompressionPolicy

type CompressionPolicy struct {
	HypertableSchema string `json:"hypertable_schema"`
	HypertableName   string `json:"hypertable_name"`
	CompressAfter    string `json:"compress_after"`
	ScheduleInterval string `json:"schedule_interval,omitempty"`
}

type CompressionSettings

type CompressionSettings struct {
	SegmentByColumns  []string        `json:"segment_by_columns,omitempty"`
	OrderByColumns    []OrderByColumn `json:"order_by_columns,omitempty"`
	ChunkTimeInterval string          `json:"chunk_time_interval,omitempty"`
}

func (*CompressionSettings) OrderByList

func (cs *CompressionSettings) OrderByList() string

func (*CompressionSettings) SegmentByList

func (cs *CompressionSettings) SegmentByList() string

type Constraint

type Constraint struct {
	Name       string   `json:"name"`
	Type       string   `json:"type"`
	Columns    []string `json:"columns"`
	Definition string   `json:"definition,omitempty"`

	ReferencedSchema  string   `json:"referenced_schema,omitempty"`
	ReferencedTable   string   `json:"referenced_table,omitempty"`
	ReferencedColumns []string `json:"referenced_columns,omitempty"`
	OnDelete          string   `json:"on_delete,omitempty"`
	OnUpdate          string   `json:"on_update,omitempty"`

	CheckExpression string `json:"check_expression,omitempty"`
	IndexName       string `json:"index_name,omitempty"`

	IsDeferrable      bool `json:"is_deferrable,omitempty"`
	InitiallyDeferred bool `json:"initially_deferred,omitempty"`
}

func (*Constraint) IsCheck

func (c *Constraint) IsCheck() bool

func (*Constraint) IsForeignKey

func (c *Constraint) IsForeignKey() bool

func (*Constraint) IsPrimaryKey

func (c *Constraint) IsPrimaryKey() bool

func (*Constraint) IsUnique

func (c *Constraint) IsUnique() bool

func (*Constraint) QualifiedReferencedTable

func (c *Constraint) QualifiedReferencedTable() string

type ContinuousAggregate

type ContinuousAggregate struct {
	Schema           string         `json:"schema"`
	ViewName         string         `json:"view_name"`
	HypertableSchema string         `json:"hypertable_schema"`
	HypertableName   string         `json:"hypertable_name"`
	Query            string         `json:"query"`
	RefreshPolicy    *RefreshPolicy `json:"refresh_policy,omitempty"`
	WithData         bool           `json:"with_data"`
	Materialized     bool           `json:"materialized"`
	Finalized        bool           `json:"finalized,omitempty"`
	Comment          string         `json:"comment,omitempty"`
	Indexes          []Index        `json:"indexes,omitempty"`
}

func (*ContinuousAggregate) QualifiedHypertableName

func (ca *ContinuousAggregate) QualifiedHypertableName() string

func (*ContinuousAggregate) QualifiedViewName

func (ca *ContinuousAggregate) QualifiedViewName() string

type CustomType

type CustomType struct {
	Schema     string   `json:"schema"`
	Name       string   `json:"name"`
	Type       string   `json:"type"`
	Definition string   `json:"definition"`
	Values     []string `json:"values,omitempty"`
	Comment    string   `json:"comment,omitempty"`
}

func (*CustomType) QualifiedName

func (ct *CustomType) QualifiedName() string

type Database

type Database struct {
	Version      string `json:"version"`
	DatabaseName string `json:"database_name"`
	ExtractedAt  string `json:"extracted_at"`

	Schemas              []Schema              `json:"schemas,omitempty"`
	Extensions           []Extension           `json:"extensions,omitempty"`
	CustomTypes          []CustomType          `json:"custom_types,omitempty"`
	Sequences            []Sequence            `json:"sequences,omitempty"`
	Tables               []Table               `json:"tables"`
	Views                []View                `json:"views,omitempty"`
	MaterializedViews    []MaterializedView    `json:"materialized_views,omitempty"`
	Functions            []Function            `json:"functions,omitempty"`
	Triggers             []Trigger             `json:"triggers,omitempty"`
	Hypertables          []Hypertable          `json:"hypertables,omitempty"`
	ContinuousAggregates []ContinuousAggregate `json:"continuous_aggregates,omitempty"`
}

func (*Database) GetContinuousAggregate

func (db *Database) GetContinuousAggregate(schema, viewName string) *ContinuousAggregate

func (*Database) GetContinuousAggregates

func (db *Database) GetContinuousAggregates() int

func (*Database) GetCustomTypes

func (db *Database) GetCustomTypes() int

func (*Database) GetExtensions

func (db *Database) GetExtensions() int

func (*Database) GetFunction

func (db *Database) GetFunction(schema, name string, argTypes []string) *Function

func (*Database) GetFunctions

func (db *Database) GetFunctions() int

func (*Database) GetHypertables

func (db *Database) GetHypertables() int

func (*Database) GetMaterializedView added in v0.4.7

func (db *Database) GetMaterializedView(schema, name string) *MaterializedView

func (*Database) GetMaterializedViews

func (db *Database) GetMaterializedViews() int

func (*Database) GetSchemas

func (db *Database) GetSchemas() int

func (*Database) GetSequences

func (db *Database) GetSequences() int

func (*Database) GetTable

func (db *Database) GetTable(schema, name string) *Table

func (*Database) GetTables

func (db *Database) GetTables() int

func (*Database) GetTriggers

func (db *Database) GetTriggers() int

func (*Database) GetView

func (db *Database) GetView(schema, name string) *View

func (*Database) GetViews

func (db *Database) GetViews() int

func (*Database) MarshalJSON

func (db *Database) MarshalJSON() ([]byte, error)

func (*Database) Sort

func (db *Database) Sort()

func (*Database) UnmarshalJSON

func (db *Database) UnmarshalJSON(data []byte) error

type Extension

type Extension struct {
	Name    string `json:"name"`
	Schema  string `json:"schema,omitempty"`
	Version string `json:"version,omitempty"`
	Comment string `json:"comment,omitempty"`
}

type Function

type Function struct {
	Schema        string   `json:"schema"`
	Name          string   `json:"name"`
	ArgumentTypes []string `json:"argument_types"`
	ArgumentNames []string `json:"argument_names,omitempty"`
	ArgumentModes []string `json:"argument_modes,omitempty"`
	ReturnType    string   `json:"return_type"`
	Language      string   `json:"language"`
	Body          string   `json:"body"`
	Volatility    string   `json:"volatility"`
	Definition    string   `json:"definition"`

	IsAggregate       bool   `json:"is_aggregate,omitempty"`
	IsWindow          bool   `json:"is_window,omitempty"`
	IsStrict          bool   `json:"is_strict,omitempty"`
	IsSecurityDefiner bool   `json:"is_security_definer,omitempty"`
	Comment           string `json:"comment,omitempty"`
	Owner             string `json:"owner,omitempty"`
}

func (*Function) ArgumentList

func (f *Function) ArgumentList() string

func (*Function) QualifiedName

func (f *Function) QualifiedName() string

func (*Function) Signature

func (f *Function) Signature() string

type Hypertable

type Hypertable struct {
	Schema    string `json:"schema"`
	TableName string `json:"table_name"`

	TimeColumnName    string `json:"time_column_name"`
	TimeColumnType    string `json:"time_column_type"`
	PartitionInterval string `json:"partition_interval"`

	SpacePartitions int      `json:"space_partitions,omitempty"`
	SpaceColumns    []string `json:"space_columns,omitempty"`

	CompressionEnabled  bool                 `json:"compression_enabled"`
	CompressionSettings *CompressionSettings `json:"compression_settings,omitempty"`
	RetentionPolicy     *RetentionPolicy     `json:"retention_policy,omitempty"`
	ChunkTimeInterval   string               `json:"chunk_time_interval,omitempty"`
	NumDimensions       int                  `json:"num_dimensions"`
}

func (*Hypertable) QualifiedTableName

func (h *Hypertable) QualifiedTableName() string

type Index

type Index struct {
	Schema    string   `json:"schema"`
	TableName string   `json:"table_name"`
	Name      string   `json:"name"`
	Columns   []string `json:"columns"`
	Type      string   `json:"type"`

	IsUnique   bool   `json:"is_unique"`
	IsPrimary  bool   `json:"is_primary"`
	Where      string `json:"where,omitempty"`
	Definition string `json:"definition"`

	IsExcludeConstraint bool              `json:"is_exclude_constraint,omitempty"`
	NullsNotDistinct    bool              `json:"nulls_not_distinct,omitempty"`
	IncludeColumns      []string          `json:"include_columns,omitempty"`
	Tablespace          string            `json:"tablespace,omitempty"`
	StorageParams       map[string]string `json:"storage_params,omitempty"`
}

func (*Index) ColumnList

func (i *Index) ColumnList() string

func (*Index) IncludeColumnList

func (i *Index) IncludeColumnList() string

func (*Index) IsCoveringIndex

func (i *Index) IsCoveringIndex() bool

func (*Index) IsExpression

func (i *Index) IsExpression() bool

func (*Index) IsPartial

func (i *Index) IsPartial() bool

func (*Index) QualifiedName

func (i *Index) QualifiedName() string

func (*Index) QualifiedTableName

func (i *Index) QualifiedTableName() string

type MaterializedView

type MaterializedView struct {
	Schema     string  `json:"schema"`
	Name       string  `json:"name"`
	Definition string  `json:"definition"`
	Comment    string  `json:"comment,omitempty"`
	Owner      string  `json:"owner,omitempty"`
	Tablespace string  `json:"tablespace,omitempty"`
	Indexes    []Index `json:"indexes,omitempty"`
	WithData   bool    `json:"with_data"`
}

func (*MaterializedView) QualifiedName

func (mv *MaterializedView) QualifiedName() string

type OrderByColumn

type OrderByColumn struct {
	Column     string `json:"column"`
	Direction  string `json:"direction"`
	NullsOrder string `json:"nulls_order,omitempty"`
}

type Partition

type Partition struct {
	Name       string `json:"name"`
	Definition string `json:"definition,omitempty"`
}

type PartitionStrategy

type PartitionStrategy struct {
	Type       string      `json:"type"`
	Columns    []string    `json:"columns"`
	Partitions []Partition `json:"partitions,omitempty"`
}

type RefreshPolicy

type RefreshPolicy struct {
	StartOffset      string `json:"start_offset"`
	EndOffset        string `json:"end_offset"`
	ScheduleInterval string `json:"schedule_interval"`
}

type RetentionPolicy

type RetentionPolicy struct {
	DropAfter        string `json:"drop_after"`
	ScheduleInterval string `json:"schedule_interval,omitempty"`
}

type Schema

type Schema struct {
	Name string `json:"name"`
}

func (*Schema) QualifiedName

func (s *Schema) QualifiedName() string

type Sequence

type Sequence struct {
	Schema        string `json:"schema"`
	Name          string `json:"name"`
	DataType      string `json:"data_type"`
	StartValue    int64  `json:"start_value"`
	MinValue      int64  `json:"min_value"`
	MaxValue      int64  `json:"max_value"`
	Increment     int64  `json:"increment"`
	CacheSize     int64  `json:"cache_size"`
	IsCyclic      bool   `json:"is_cyclic"`
	OwnedByTable  string `json:"owned_by_table,omitempty"`
	OwnedByColumn string `json:"owned_by_column,omitempty"`
}

func (*Sequence) QualifiedName

func (s *Sequence) QualifiedName() string

type Table

type Table struct {
	Schema            string             `json:"schema"`
	Name              string             `json:"name"`
	Columns           []Column           `json:"columns"`
	Constraints       []Constraint       `json:"constraints,omitempty"`
	Indexes           []Index            `json:"indexes,omitempty"`
	Comment           string             `json:"comment,omitempty"`
	Owner             string             `json:"owner,omitempty"`
	Tablespace        string             `json:"tablespace,omitempty"`
	PartitionStrategy *PartitionStrategy `json:"partition_strategy,omitempty"`
}

func (*Table) GetColumn

func (t *Table) GetColumn(name string) *Column

func (*Table) GetConstraint

func (t *Table) GetConstraint(name string) *Constraint

func (*Table) GetIndex

func (t *Table) GetIndex(name string) *Index

func (*Table) GetPrimaryKey

func (t *Table) GetPrimaryKey() *Constraint

func (*Table) QualifiedName

func (t *Table) QualifiedName() string

func (*Table) Sort

func (t *Table) Sort()

type Trigger

type Trigger struct {
	Schema         string   `json:"schema"`
	Name           string   `json:"name"`
	TableName      string   `json:"table_name"`
	Timing         string   `json:"timing"`
	Events         []string `json:"events"`
	ForEachRow     bool     `json:"for_each_row"`
	WhenCondition  string   `json:"when_condition,omitempty"`
	FunctionSchema string   `json:"function_schema"`
	FunctionName   string   `json:"function_name"`
	Definition     string   `json:"definition"`
	Comment        string   `json:"comment,omitempty"`
}

func (*Trigger) EventList

func (t *Trigger) EventList() string

func (*Trigger) QualifiedFunctionName

func (t *Trigger) QualifiedFunctionName() string

func (*Trigger) QualifiedTableName

func (t *Trigger) QualifiedTableName() string

type View

type View struct {
	Schema      string `json:"schema"`
	Name        string `json:"name"`
	Definition  string `json:"definition"`
	Comment     string `json:"comment,omitempty"`
	Owner       string `json:"owner,omitempty"`
	CheckOption string `json:"check_option,omitempty"`
	IsUpdatable bool   `json:"is_updatable,omitempty"`
}

func (*View) QualifiedName

func (v *View) QualifiedName() string

Jump to

Keyboard shortcuts

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