Documentation
¶
Index ¶
- func EscapeIdentifier(name string) string
- func FQEscapedColumnName(table SchemaQualifiedName, columnName string) string
- type CheckConstraint
- type Column
- type Extension
- type ForeignKeyConstraint
- type Function
- type GetIndexDefStatement
- type GetTriggerDefStatement
- type Index
- type IndexConstraint
- type IndexConstraintType
- type Object
- type ReplicaIdentity
- type Schema
- type SchemaQualifiedName
- type Sequence
- type SequenceOwner
- type Table
- type Trigger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EscapeIdentifier ¶
func FQEscapedColumnName ¶ added in v0.2.0
func FQEscapedColumnName(table SchemaQualifiedName, columnName string) string
FQEscapedColumnName builds a fully-qualified escape column name
Types ¶
type CheckConstraint ¶
type CheckConstraint struct {
Name string
Expression string
IsValid bool
IsInheritable bool
DependsOnFunctions []SchemaQualifiedName
}
func (CheckConstraint) GetName ¶
func (c CheckConstraint) GetName() string
type Column ¶
type Column struct {
Name string
Type string
Collation SchemaQualifiedName
// If the column has a default value, this will be a SQL string representing that value.
// Examples:
// ”::text
// CURRENT_TIMESTAMP
// If empty, indicates that there is no default value.
Default string
IsNullable bool
// Size is the number of bytes required to store the value.
// It is used for data-packing purposes
Size int //
}
func (Column) IsCollated ¶
type Extension ¶ added in v0.3.0
type Extension struct {
SchemaQualifiedName
Version string
}
type ForeignKeyConstraint ¶ added in v0.3.0
type ForeignKeyConstraint struct {
EscapedName string
OwningTable SchemaQualifiedName
// TableUnescapedName is a hackaround until we switch over Tables to use fully-qualified, escaped names
OwningTableUnescapedName string
ForeignTable SchemaQualifiedName
// ForeignTableUnescapedName is hackaround for the same as above
ForeignTableUnescapedName string
ConstraintDef string
IsValid bool
}
func (ForeignKeyConstraint) GetName ¶ added in v0.3.0
func (f ForeignKeyConstraint) GetName() string
type Function ¶
type Function struct {
SchemaQualifiedName
// FunctionDef is the statement required to completely (re)create
// the function, as returned by `pg_get_functiondef`. It is a CREATE OR REPLACE
// statement
FunctionDef string
// Language is the language of the function. This is relevant in determining if we
// can track the dependencies of the function (or not)
Language string
DependsOnFunctions []SchemaQualifiedName
}
type GetIndexDefStatement ¶
type GetIndexDefStatement string
GetIndexDefStatement is the output of pg_getindexdef. It is a `CREATE INDEX` statement that will re-create the index. This statement does not contain `CONCURRENTLY`. For unique indexes, it does contain `UNIQUE` For partitioned tables, it does contain `ONLY`
func (GetIndexDefStatement) ToCreateIndexConcurrently ¶
func (i GetIndexDefStatement) ToCreateIndexConcurrently() (string, error)
type GetTriggerDefStatement ¶
type GetTriggerDefStatement string
GetTriggerDefStatement is the output of pg_get_triggerdef. It is a `CREATE TRIGGER` statement that will create the trigger. This statement does not contain `OR REPLACE`
func (GetTriggerDefStatement) ToCreateOrReplace ¶
func (g GetTriggerDefStatement) ToCreateOrReplace() (string, error)
type Index ¶
type Index struct {
TableName string
Name string
Columns []string
IsInvalid bool
IsUnique bool
Constraint *IndexConstraint
// GetIndexDefStmt is the output of pg_getindexdef
GetIndexDefStmt GetIndexDefStatement
// ParentIdxName is the name of the parent index if the index is a partition of an index
ParentIdxName string
}
func (Index) IsPartitionOfIndex ¶
type IndexConstraint ¶ added in v0.4.0
type IndexConstraint struct {
Type IndexConstraintType
EscapedConstraintName string
ConstraintDef string
IsLocal bool
}
IndexConstraint informally represents a constraint that is always 1:1 with an index, i.e., primary and unique constraints. It's easiest to just treat these like a property of the index rather than a separate entity
type IndexConstraintType ¶ added in v0.4.0
type IndexConstraintType string
const (
PkIndexConstraintType IndexConstraintType = "p"
)
type Object ¶
type Object interface {
// GetName is used to identify the old and new versions of a schema object between the old and new schemas
// If the name is not present in the old schema objects list, then it is added
// If the name is not present in the new schemas objects list, then it is removed
// Otherwise, it has persisted across two schemas and is possibly altered
GetName() string
}
Object represents a resource in a schema (table, column, index...)
type ReplicaIdentity ¶ added in v0.4.0
type ReplicaIdentity string
const ( ReplicaIdentityDefault ReplicaIdentity = "d" ReplicaIdentityNothing ReplicaIdentity = "n" ReplicaIdentityFull ReplicaIdentity = "f" ReplicaIdentityIndex ReplicaIdentity = "i" )
type Schema ¶
type Schema struct {
Extensions []Extension
Tables []Table
Indexes []Index
ForeignKeyConstraints []ForeignKeyConstraint
Sequences []Sequence
Functions []Function
Triggers []Trigger
}
func GetPublicSchema ¶
GetPublicSchema fetches the "public" schema. It is a non-atomic operation.
type SchemaQualifiedName ¶
type SchemaQualifiedName struct {
SchemaName string
// EscapedName is the name of the object. It should already be escaped
// We take an escaped name because there are weird exceptions, like functions, where we can't just
// surround the name in quotes
EscapedName string
}
SchemaQualifiedName represents a schema object name scoped within a schema
func (SchemaQualifiedName) GetFQEscapedName ¶
func (o SchemaQualifiedName) GetFQEscapedName() string
GetFQEscapedName gets the fully-qualified, escaped name of the schema object, including the schema name
func (SchemaQualifiedName) GetName ¶
func (o SchemaQualifiedName) GetName() string
func (SchemaQualifiedName) IsEmpty ¶
func (o SchemaQualifiedName) IsEmpty() bool
type Sequence ¶ added in v0.2.0
type Sequence struct {
SchemaQualifiedName
Owner *SequenceOwner
Type string
StartValue int64
Increment int64
MaxValue int64
MinValue int64
CacheSize int64
Cycle bool
}
type SequenceOwner ¶ added in v0.2.0
type SequenceOwner struct {
TableName SchemaQualifiedName
// TableUnescapedName is a hackaround until we switch over Tables to use fully-qualified, escaped names
TableUnescapedName string
ColumnName string
}
SequenceOwner represents the owner of a sequence. Once we remove TableUnescapedName, we can replace it with ColumnIdentifier struct that can also be used in the Column struct
type Table ¶
type Table struct {
Name string
Columns []Column
CheckConstraints []CheckConstraint
ReplicaIdentity ReplicaIdentity
// PartitionKeyDef is the output of Pg function pg_get_partkeydef:
// PARTITION BY $PartitionKeyDef
// If empty, then the table is not partitioned
PartitionKeyDef string
ParentTableName string
ForValues string
}
func (Table) IsPartition ¶
func (Table) IsPartitioned ¶
type Trigger ¶
type Trigger struct {
EscapedName string
OwningTable SchemaQualifiedName
// OwningTableUnescapedName lets us be backwards compatible with the TableSQLVertexGenerator, which
// currently uses the unescaped name as the vertex id. This will be removed once the TableSQLVertexGenerator
// is migrated to use SchemaQualifiedName
OwningTableUnescapedName string
Function SchemaQualifiedName
// GetTriggerDefStmt is the statement required to completely (re)create the trigger, as returned
// by pg_get_triggerdef
GetTriggerDefStmt GetTriggerDefStatement
}