Documentation
¶
Index ¶
- func GenerateMigration(engine storepb.Engine, diff *MetadataDiff) (string, error)
- func GetFunctionDefinition(engine storepb.Engine, schemaName string, function *storepb.FunctionMetadata) (string, error)
- func GetMaterializedViewDefinition(engine storepb.Engine, schemaName string, ...) (string, error)
- func GetProcedureDefinition(engine storepb.Engine, schemaName string, procedure *storepb.ProcedureMetadata) (string, error)
- func GetTableDefinition(engine storepb.Engine, schemaName string, table *storepb.TableMetadata, ...) (string, error)
- func GetViewDefinition(engine storepb.Engine, schemaName string, view *storepb.ViewMetadata) (string, error)
- func RegisterGenerateMigration(engine storepb.Engine, f generateMigration)
- func RegisterGetFunctionDefinition(engine storepb.Engine, f getFunctionDefinition)
- func RegisterGetMaterializedViewDefinition(engine storepb.Engine, f getMaterializedViewDefinition)
- func RegisterGetProcedureDefinition(engine storepb.Engine, f getProcedureDefinition)
- func RegisterGetTableDefinition(engine storepb.Engine, f getTableDefinition)
- func RegisterGetViewDefinition(engine storepb.Engine, f getViewDefinition)
- type CheckConstraintDiff
- type ColumnDiff
- type CommentDiff
- type CommentObjectType
- type EnumTypeDiff
- type EventDiff
- type EventTriggerDiff
- type ExtensionDiff
- type ForeignKeyDiff
- type FunctionDiff
- type IndexDiff
- type MaterializedViewDiff
- type MetadataDiff
- type MetadataDiffAction
- type PartitionDiff
- type ProcedureDiff
- type SchemaDiff
- type SequenceDiff
- type TableDiff
- type TriggerDiff
- type ViewDiff
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateMigration ¶
func GenerateMigration(engine storepb.Engine, diff *MetadataDiff) (string, error)
GenerateMigration generates DDL migration SQL from a MetadataDiff for the given engine.
func GetFunctionDefinition ¶
func GetProcedureDefinition ¶
func GetTableDefinition ¶
func GetTableDefinition(engine storepb.Engine, schemaName string, table *storepb.TableMetadata, sequences []*storepb.SequenceMetadata) (string, error)
func GetViewDefinition ¶
func RegisterGenerateMigration ¶
RegisterGenerateMigration registers a generate migration function for an engine.
Types ¶
type CheckConstraintDiff ¶
type CheckConstraintDiff struct {
Action MetadataDiffAction
CheckConstraintName string
OldCheckConstraint *storepb.CheckConstraintMetadata
NewCheckConstraint *storepb.CheckConstraintMetadata
}
CheckConstraintDiff represents changes to a check constraint.
type ColumnDiff ¶
type ColumnDiff struct {
Action MetadataDiffAction
OldColumn *storepb.ColumnMetadata
NewColumn *storepb.ColumnMetadata
}
ColumnDiff represents changes to a column.
type CommentDiff ¶
type CommentDiff struct {
Action MetadataDiffAction
SchemaName string
ObjectType CommentObjectType
ObjectName string
OldComment string
NewComment string
}
CommentDiff represents changes to a comment.
type CommentObjectType ¶
type CommentObjectType string
CommentObjectType represents the type of object a comment belongs to.
const ( CommentObjectTypeTable CommentObjectType = "TABLE" CommentObjectTypeColumn CommentObjectType = "COLUMN" CommentObjectTypeView CommentObjectType = "VIEW" CommentObjectTypeMaterializedView CommentObjectType = "MATERIALIZED_VIEW" CommentObjectTypeFunction CommentObjectType = "FUNCTION" CommentObjectTypeSequence CommentObjectType = "SEQUENCE" CommentObjectTypeSchema CommentObjectType = "SCHEMA" CommentObjectTypeIndex CommentObjectType = "INDEX" )
type EnumTypeDiff ¶
type EnumTypeDiff struct {
Action MetadataDiffAction
SchemaName string
EnumTypeName string
OldEnumType *storepb.EnumTypeMetadata
NewEnumType *storepb.EnumTypeMetadata
}
EnumTypeDiff represents changes to an enum type.
type EventDiff ¶
type EventDiff struct {
Action MetadataDiffAction
SchemaName string
EventName string
OldEvent *storepb.EventMetadata
NewEvent *storepb.EventMetadata
}
EventDiff represents changes to an event.
type EventTriggerDiff ¶
type EventTriggerDiff struct {
Action MetadataDiffAction
EventTriggerName string
OldEventTrigger *storepb.EventTriggerMetadata
NewEventTrigger *storepb.EventTriggerMetadata
}
EventTriggerDiff represents changes to an event trigger.
type ExtensionDiff ¶
type ExtensionDiff struct {
Action MetadataDiffAction
ExtensionName string
OldExtension *storepb.ExtensionMetadata
NewExtension *storepb.ExtensionMetadata
}
ExtensionDiff represents changes to an extension.
type ForeignKeyDiff ¶
type ForeignKeyDiff struct {
Action MetadataDiffAction
ForeignKeyName string
OldForeignKey *storepb.ForeignKeyMetadata
NewForeignKey *storepb.ForeignKeyMetadata
}
ForeignKeyDiff represents changes to a foreign key.
type FunctionDiff ¶
type FunctionDiff struct {
Action MetadataDiffAction
SchemaName string
FunctionName string
OldFunction *storepb.FunctionMetadata
NewFunction *storepb.FunctionMetadata
}
FunctionDiff represents changes to a function.
type IndexDiff ¶
type IndexDiff struct {
Action MetadataDiffAction
IndexName string
OldIndex *storepb.IndexMetadata
NewIndex *storepb.IndexMetadata
}
IndexDiff represents changes to an index.
type MaterializedViewDiff ¶
type MaterializedViewDiff struct {
Action MetadataDiffAction
SchemaName string
MaterializedViewName string
OldMaterializedView *storepb.MaterializedViewMetadata
NewMaterializedView *storepb.MaterializedViewMetadata
}
MaterializedViewDiff represents changes to a materialized view.
type MetadataDiff ¶
type MetadataDiff struct {
DatabaseName string
SchemaChanges []*SchemaDiff
TableChanges []*TableDiff
ViewChanges []*ViewDiff
MaterializedViewChanges []*MaterializedViewDiff
FunctionChanges []*FunctionDiff
ProcedureChanges []*ProcedureDiff
SequenceChanges []*SequenceDiff
EnumTypeChanges []*EnumTypeDiff
ExtensionChanges []*ExtensionDiff
EventTriggerChanges []*EventTriggerDiff
EventChanges []*EventDiff
CommentChanges []*CommentDiff
}
MetadataDiff represents the differences between two database schemas.
func GetDatabaseSchemaDiff ¶
func GetDatabaseSchemaDiff(engine storepb.Engine, oldSchema, newSchema *storepb.DatabaseSchemaMetadata) (*MetadataDiff, error)
GetDatabaseSchemaDiff compares two DatabaseSchemaMetadata instances and returns the differences.
type MetadataDiffAction ¶
type MetadataDiffAction string
MetadataDiffAction represents the type of change action.
const ( MetadataDiffActionCreate MetadataDiffAction = "CREATE" MetadataDiffActionDrop MetadataDiffAction = "DROP" MetadataDiffActionAlter MetadataDiffAction = "ALTER" )
type PartitionDiff ¶
type PartitionDiff struct {
Action MetadataDiffAction
PartitionName string
OldPartition *storepb.TablePartitionMetadata
NewPartition *storepb.TablePartitionMetadata
}
PartitionDiff represents changes to a partition.
type ProcedureDiff ¶
type ProcedureDiff struct {
Action MetadataDiffAction
SchemaName string
ProcedureName string
OldProcedure *storepb.ProcedureMetadata
NewProcedure *storepb.ProcedureMetadata
}
ProcedureDiff represents changes to a procedure.
type SchemaDiff ¶
type SchemaDiff struct {
Action MetadataDiffAction
SchemaName string
OldSchema *storepb.SchemaMetadata
NewSchema *storepb.SchemaMetadata
}
SchemaDiff represents changes to a schema.
type SequenceDiff ¶
type SequenceDiff struct {
Action MetadataDiffAction
SchemaName string
SequenceName string
OldSequence *storepb.SequenceMetadata
NewSequence *storepb.SequenceMetadata
}
SequenceDiff represents changes to a sequence.
type TableDiff ¶
type TableDiff struct {
Action MetadataDiffAction
SchemaName string
TableName string
OldTable *storepb.TableMetadata
NewTable *storepb.TableMetadata
ColumnChanges []*ColumnDiff
IndexChanges []*IndexDiff
ForeignKeyChanges []*ForeignKeyDiff
CheckConstraintChanges []*CheckConstraintDiff
TriggerChanges []*TriggerDiff
PartitionChanges []*PartitionDiff
}
TableDiff represents changes to a table.
type TriggerDiff ¶
type TriggerDiff struct {
Action MetadataDiffAction
TriggerName string
OldTrigger *storepb.TriggerMetadata
NewTrigger *storepb.TriggerMetadata
}
TriggerDiff represents changes to a trigger.
type ViewDiff ¶
type ViewDiff struct {
Action MetadataDiffAction
SchemaName string
ViewName string
OldView *storepb.ViewMetadata
NewView *storepb.ViewMetadata
}
ViewDiff represents changes to a view.