schema

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareExpressionsSemantically

func CompareExpressionsSemantically(engine storepb.Engine, expr1, expr2 string) bool

CompareExpressionsSemantically compares two expressions semantically based on the engine type.

func GenerateMigration

func GenerateMigration(engine storepb.Engine, diff *MetadataDiff) (string, error)

func GetDatabaseDefinition

func GetDatabaseDefinition(engine storepb.Engine, ctx GetDefinitionContext, metadata *storepb.DatabaseSchemaMetadata) (string, error)

func GetDatabaseMetadata

func GetDatabaseMetadata(engine storepb.Engine, schemaText string) (*storepb.DatabaseSchemaMetadata, error)

func GetFunctionDefinition

func GetFunctionDefinition(engine storepb.Engine, functionName string, function *storepb.FunctionMetadata) (string, error)

func GetMaterializedViewDefinition

func GetMaterializedViewDefinition(engine storepb.Engine, viewName string, view *storepb.MaterializedViewMetadata) (string, error)

func GetProcedureDefinition

func GetProcedureDefinition(engine storepb.Engine, procedureName string, procedure *storepb.ProcedureMetadata) (string, error)

func GetSchemaDefinition

func GetSchemaDefinition(engine storepb.Engine, schema *storepb.SchemaMetadata) (string, error)

func GetSequenceDefinition

func GetSequenceDefinition(engine storepb.Engine, sequenceName string, sequence *storepb.SequenceMetadata) (string, error)

func GetTableDefinition

func GetTableDefinition(engine storepb.Engine, tableName string, table *storepb.TableMetadata, sequences []*storepb.SequenceMetadata) (string, error)

func GetViewDefinition

func GetViewDefinition(engine storepb.Engine, viewName string, view *storepb.ViewMetadata) (string, error)

func RegisterFunctionComparer

func RegisterFunctionComparer(engine storepb.Engine, comparer FunctionComparer)

RegisterFunctionComparer registers a function comparer for a specific engine.

func RegisterGenerateMigration

func RegisterGenerateMigration(engine storepb.Engine, f generateMigration)

func RegisterGetDatabaseDefinition

func RegisterGetDatabaseDefinition(engine storepb.Engine, f getDatabaseDefinition)

func RegisterGetDatabaseMetadata

func RegisterGetDatabaseMetadata(engine storepb.Engine, f getDatabaseMetadata)

func RegisterGetFunctionDefinition

func RegisterGetFunctionDefinition(engine storepb.Engine, f getFunctionDefinition)

func RegisterGetMaterializedViewDefinition

func RegisterGetMaterializedViewDefinition(engine storepb.Engine, f getMaterializedViewDefinition)

func RegisterGetMultiFileDatabaseDefinition

func RegisterGetMultiFileDatabaseDefinition(engine storepb.Engine, f getMultiFileDatabaseDefinition)

func RegisterGetProcedureDefinition

func RegisterGetProcedureDefinition(engine storepb.Engine, f getProcedureDefinition)

func RegisterGetSDLDiff

func RegisterGetSDLDiff(engine storepb.Engine, f getSDLDiff)

func RegisterGetSchemaDefinition

func RegisterGetSchemaDefinition(engine storepb.Engine, f getSchemaDefinition)

func RegisterGetSequenceDefinition

func RegisterGetSequenceDefinition(engine storepb.Engine, f getSequenceDefinition)

func RegisterGetTableDefinition

func RegisterGetTableDefinition(engine storepb.Engine, f getTableDefinition)

func RegisterGetViewDefinition

func RegisterGetViewDefinition(engine storepb.Engine, f getViewDefinition)

func RegisterIndexComparer

func RegisterIndexComparer(engine storepb.Engine, comparer IndexComparer)

RegisterIndexComparer registers an index comparer for a specific engine.

func RegisterViewComparer

func RegisterViewComparer(engine storepb.Engine, comparer ViewComparer)

RegisterViewComparer registers a view comparer for a specific engine.

func RegisterWalkThrough

func RegisterWalkThrough(engine storepb.Engine, f walkThrough)

func WalkThrough

func WalkThrough(engine storepb.Engine, d *model.DatabaseMetadata, ast []base.AST) *storepb.Advice

Types

type CheckConstraintDiff

type CheckConstraintDiff struct {
	Action             MetadataDiffAction
	OldCheckConstraint *storepb.CheckConstraintMetadata
	NewCheckConstraint *storepb.CheckConstraintMetadata
	OldASTNode         any // AST node for old check constraint
	NewASTNode         any // AST node for new check constraint
}

CheckConstraintDiff represents changes to a check constraint.

type ColumnDiff

type ColumnDiff struct {
	Action    MetadataDiffAction
	OldColumn *storepb.ColumnMetadata
	NewColumn *storepb.ColumnMetadata

	// AST nodes for DDL analysis and generation
	OldASTNode parser.IColumnDefContext // Previous column definition AST node
	NewASTNode parser.IColumnDefContext // Current column definition AST node
}

ColumnDiff represents changes to a column.

type CommentDiff

type CommentDiff struct {
	Action     MetadataDiffAction // CREATE or ALTER (no DROP since object deletion removes comments automatically)
	ObjectType CommentObjectType
	SchemaName string
	TableName  string // used for TRIGGER comments (COMMENT ON TRIGGER trigger_name ON table_name)
	ObjectName string // table/view/function/sequence/index name
	ColumnName string // only used for COLUMN comments
	IndexName  string // only used for table-level INDEX comments
	OldComment string
	NewComment string
	OldASTNode antlr.ParserRuleContext
	NewASTNode antlr.ParserRuleContext
}

CommentDiff represents changes to database object comments. Comments are tracked independently to avoid triggering object recreation when only comments change.

type CommentObjectType

type CommentObjectType string

CommentObjectType represents the type of database object that has a comment.

const (
	CommentObjectTypeSchema           CommentObjectType = "SCHEMA"
	CommentObjectTypeTable            CommentObjectType = "TABLE"
	CommentObjectTypeColumn           CommentObjectType = "COLUMN"
	CommentObjectTypeView             CommentObjectType = "VIEW"
	CommentObjectTypeMaterializedView CommentObjectType = "MATERIALIZED VIEW"
	CommentObjectTypeFunction         CommentObjectType = "FUNCTION"
	CommentObjectTypeSequence         CommentObjectType = "SEQUENCE"
	CommentObjectTypeIndex            CommentObjectType = "INDEX"
	CommentObjectTypeTrigger          CommentObjectType = "TRIGGER"
	CommentObjectTypeType             CommentObjectType = "TYPE"
	CommentObjectTypeExtension        CommentObjectType = "EXTENSION"
	CommentObjectTypeEventTrigger     CommentObjectType = "EVENT TRIGGER"
)

type DefaultFunctionComparer

type DefaultFunctionComparer struct{}

DefaultFunctionComparer provides default function comparison logic that can be used by most engines.

func (*DefaultFunctionComparer) CompareDetailed

func (*DefaultFunctionComparer) CompareDetailed(oldFunc, newFunc *storepb.FunctionMetadata) (*FunctionComparisonResult, error)

CompareDetailed provides basic comparison for engines that don't have advanced comparison logic.

func (*DefaultFunctionComparer) Equal

func (*DefaultFunctionComparer) Equal(oldFunc, newFunc *storepb.FunctionMetadata) bool

Equal compares two functions using simple definition comparison.

type DefaultIndexComparer

type DefaultIndexComparer struct{}

DefaultIndexComparer provides default index comparison logic using simple string matching.

func (*DefaultIndexComparer) CompareIndexWhereConditions

func (c *DefaultIndexComparer) CompareIndexWhereConditions(def1, def2 string) bool

CompareIndexWhereConditions provides a default implementation using simple string extraction.

func (*DefaultIndexComparer) ExtractWhereClauseFromIndexDef

func (*DefaultIndexComparer) ExtractWhereClauseFromIndexDef(definition string) string

ExtractWhereClauseFromIndexDef provides a default implementation using simple string matching.

type DefaultViewComparer

type DefaultViewComparer struct{}

DefaultViewComparer provides default view comparison logic that can be used by most engines.

func (*DefaultViewComparer) CompareMaterializedView

func (*DefaultViewComparer) CompareMaterializedView(oldMV, newMV *storepb.MaterializedViewMetadata) ([]MaterializedViewChange, error)

CompareMaterializedView compares two materialized views using default logic.

func (*DefaultViewComparer) CompareView

func (*DefaultViewComparer) CompareView(oldView, newView *storepb.ViewMetadata) ([]ViewChange, error)

CompareView compares two views using default logic.

type EnumTypeDiff

type EnumTypeDiff struct {
	Action       MetadataDiffAction
	SchemaName   string
	EnumTypeName string
	OldEnumType  *storepb.EnumTypeMetadata
	NewEnumType  *storepb.EnumTypeMetadata
	OldASTNode   any // For SDL/AST-only mode
	NewASTNode   any // For SDL/AST-only mode
}

EnumTypeDiff represents changes to an enum type.

type EventDiff

type EventDiff struct {
	Action    MetadataDiffAction
	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
	OldASTNode       any // For SDL/AST-only mode
	NewASTNode       any // For SDL/AST-only mode
}

EventTriggerDiff represents changes to an event trigger.

type ExcludeConstraintDiff

type ExcludeConstraintDiff struct {
	Action               MetadataDiffAction
	OldExcludeConstraint *storepb.ExcludeConstraintMetadata
	NewExcludeConstraint *storepb.ExcludeConstraintMetadata
	OldASTNode           any // AST node for old EXCLUDE constraint
	NewASTNode           any // AST node for new EXCLUDE constraint
}

ExcludeConstraintDiff represents changes to an EXCLUDE constraint (PostgreSQL specific).

type ExtensionDiff

type ExtensionDiff struct {
	Action        MetadataDiffAction
	ExtensionName string
	OldExtension  *storepb.ExtensionMetadata
	NewExtension  *storepb.ExtensionMetadata
	OldASTNode    any // For SDL/AST-only mode
	NewASTNode    any // For SDL/AST-only mode
}

ExtensionDiff represents changes to an extension.

type File

type File struct {
	// Name is the file path or name (e.g., "schemas/public/tables/users.sql")
	Name string
	// Content is the file content
	Content string
}

File represents a single file in a multi-file schema output.

type ForeignKeyDiff

type ForeignKeyDiff struct {
	Action        MetadataDiffAction
	OldForeignKey *storepb.ForeignKeyMetadata
	NewForeignKey *storepb.ForeignKeyMetadata
	OldASTNode    any // AST node for old foreign key constraint
	NewASTNode    any // AST node for new foreign key constraint
}

ForeignKeyDiff represents changes to a foreign key.

type FunctionChange

type FunctionChange struct {
	Type                FunctionChangeType
	Description         string
	RequiresRecreation  bool
	CanUseAlterFunction bool
}

FunctionChange represents a type of change detected in a function.

type FunctionChangeType

type FunctionChangeType string

FunctionChangeType represents specific types of function changes.

const (
	FunctionChangeDefinition FunctionChangeType = "definition"
	FunctionChangeComment    FunctionChangeType = "comment"
	FunctionChangeAttribute  FunctionChangeType = "attribute"
)

type FunctionComparer

type FunctionComparer interface {
	// Equal compares two functions and returns whether they are equal.
	Equal(oldFunc, newFunc *storepb.FunctionMetadata) bool

	// CompareDetailed performs detailed comparison and returns migration strategy information.
	// Returns nil if functions are equal.
	CompareDetailed(oldFunc, newFunc *storepb.FunctionMetadata) (*FunctionComparisonResult, error)
}

FunctionComparer provides an interface for engine-specific function comparison logic.

func GetFunctionComparer

func GetFunctionComparer(engine storepb.Engine) FunctionComparer

GetFunctionComparer returns the function comparer for a specific engine. If no engine-specific comparer is registered, it returns the default comparer.

type FunctionComparisonResult

type FunctionComparisonResult struct {
	SignatureChanged    bool
	BodyChanged         bool
	AttributesChanged   bool
	ChangedAttributes   []string
	RequiresRecreation  bool
	CanUseAlterFunction bool
}

FunctionComparisonResult contains detailed information about function changes.

type FunctionDiff

type FunctionDiff struct {
	Action       MetadataDiffAction
	SchemaName   string
	FunctionName string
	OldFunction  *storepb.FunctionMetadata
	NewFunction  *storepb.FunctionMetadata
	OldASTNode   any // AST node for old function
	NewASTNode   any // AST node for new function

	// Detailed change information for advanced engines
	SignatureChanged    bool
	BodyChanged         bool
	AttributesChanged   bool
	ChangedAttributes   []string
	CanUseAlterFunction bool
}

FunctionDiff represents changes to a function.

type GetDefinitionContext

type GetDefinitionContext struct {
	SkipBackupSchema bool
	PrintHeader      bool
	SDLFormat        bool
	// MultiFileFormat indicates whether to generate multi-file SDL output.
	// When true, the result should be organized as multiple files.
	MultiFileFormat bool
}

type IndexComparer

type IndexComparer interface {
	// CompareIndexWhereConditions compares WHERE conditions from two index definitions
	CompareIndexWhereConditions(def1, def2 string) bool

	// ExtractWhereClauseFromIndexDef extracts the WHERE clause from an index definition
	ExtractWhereClauseFromIndexDef(definition string) string
}

IndexComparer provides database-specific index comparison logic.

func GetIndexComparer

func GetIndexComparer(engine storepb.Engine) IndexComparer

GetIndexComparer returns the registered index comparer for the given engine.

type IndexDiff

type IndexDiff struct {
	Action     MetadataDiffAction
	OldIndex   *storepb.IndexMetadata
	NewIndex   *storepb.IndexMetadata
	OldASTNode any // AST node for old index constraint
	NewASTNode any // AST node for new index constraint
}

IndexDiff represents changes to an index.

type MaterializedViewChange

type MaterializedViewChange struct {
	Type        MaterializedViewChangeType
	Description string
	// RequiresRecreation indicates if the change requires dropping and recreating the materialized view.
	RequiresRecreation bool
}

MaterializedViewChange represents a detected change in a materialized view.

type MaterializedViewChangeType

type MaterializedViewChangeType int

MaterializedViewChangeType represents the type of change detected in a materialized view.

const (
	// MaterializedViewChangeNone indicates no change.
	MaterializedViewChangeNone MaterializedViewChangeType = iota
	// MaterializedViewChangeDefinition indicates the materialized view definition has changed.
	MaterializedViewChangeDefinition
	// MaterializedViewChangeComment indicates only the comment has changed.
	MaterializedViewChangeComment
	// MaterializedViewChangeIndex indicates indexes have changed.
	MaterializedViewChangeIndex
	// MaterializedViewChangeTrigger indicates triggers have changed.
	MaterializedViewChangeTrigger
	// MaterializedViewChangeOther indicates other metadata changes.
	MaterializedViewChangeOther
)

type MaterializedViewDiff

type MaterializedViewDiff struct {
	Action               MetadataDiffAction
	SchemaName           string
	MaterializedViewName string
	OldMaterializedView  *storepb.MaterializedViewMetadata
	NewMaterializedView  *storepb.MaterializedViewMetadata
	OldASTNode           any          // AST node for old materialized view
	NewASTNode           any          // AST node for new materialized view
	IndexChanges         []*IndexDiff // Index changes on materialized view
}

MaterializedViewDiff represents changes to a materialized view.

type MetadataDiff

type MetadataDiff struct {
	// Database level changes
	DatabaseName string

	// Schema changes
	SchemaChanges []*SchemaDiff

	// Table changes
	TableChanges []*TableDiff

	// View changes
	ViewChanges []*ViewDiff

	// MaterializedView changes
	MaterializedViewChanges []*MaterializedViewDiff

	// Function changes
	FunctionChanges []*FunctionDiff

	// Procedure changes
	ProcedureChanges []*ProcedureDiff

	// Sequence changes
	SequenceChanges []*SequenceDiff

	// Enum type changes
	EnumTypeChanges []*EnumTypeDiff

	// Extension changes
	ExtensionChanges []*ExtensionDiff

	// Event trigger changes
	EventTriggerChanges []*EventTriggerDiff

	// Event changes
	EventChanges []*EventDiff

	// Comment changes
	CommentChanges []*CommentDiff
}

MetadataDiff represents the differences between two database schemas.

func FilterPostgresArchiveSchema

func FilterPostgresArchiveSchema(diff *MetadataDiff) *MetadataDiff

FilterPostgresArchiveSchema filters out schema diff objects related to bbdataarchive schema.

func GetDatabaseSchemaDiff

func GetDatabaseSchemaDiff(engine storepb.Engine, oldSchema, newSchema *model.DatabaseMetadata) (*MetadataDiff, error)

GetDatabaseSchemaDiff compares two model.DatabaseMetadata instances and returns the differences.

func GetSDLDiff

func GetSDLDiff(engine storepb.Engine, currentSDLText, previousUserSDLText string, currentSchema, previousSchema *model.DatabaseMetadata) (*MetadataDiff, error)

type MetadataDiffAction

type MetadataDiffAction string

MetadataDiffAction represents the type of change action.

const (
	MetadataDiffActionCreate MetadataDiffAction = "CREATE"
	MetadataDiffActionDrop   MetadataDiffAction = "DROP"
	MetadataDiffActionAlter  MetadataDiffAction = "ALTER"
)

type MultiFileSchemaResult

type MultiFileSchemaResult struct {
	// Files is the list of schema files organized by type
	Files []File
}

MultiFileSchemaResult represents the result of multi-file schema generation.

type PartitionDiff

type PartitionDiff struct {
	Action       MetadataDiffAction
	OldPartition *storepb.TablePartitionMetadata
	NewPartition *storepb.TablePartitionMetadata
}

PartitionDiff represents changes to table partitions.

type PrimaryKeyDiff

type PrimaryKeyDiff struct {
	Action        MetadataDiffAction
	OldPrimaryKey *storepb.IndexMetadata
	NewPrimaryKey *storepb.IndexMetadata
	OldASTNode    any // AST node for old primary key constraint
	NewASTNode    any // AST node for new primary key constraint
}

PrimaryKeyDiff represents changes to a primary key constraint.

type ProcedureDiff

type ProcedureDiff struct {
	Action        MetadataDiffAction
	SchemaName    string
	ProcedureName string
	OldProcedure  *storepb.ProcedureMetadata
	NewProcedure  *storepb.ProcedureMetadata
	OldASTNode    any // AST node for old procedure
	NewASTNode    any // AST node for new procedure
}

ProcedureDiff represents changes to a procedure.

type SDLChunk

type SDLChunk struct {
	Identifier        string
	ASTNode           antlr.ParserRuleContext   // The parsed AST node for this chunk (e.g., CREATE SEQUENCE)
	AlterStatements   []antlr.ParserRuleContext // Additional ALTER statements for this object (e.g., ALTER SEQUENCE OWNED BY)
	CommentStatements []antlr.ParserRuleContext // COMMENT ON statements for this object
}

func (*SDLChunk) GetText

func (c *SDLChunk) GetText() string

GetText extracts text from the AST node using its own token stream For chunks with ALTER statements, it combines the main statement with all ALTER statements For chunks with COMMENT statements, it combines them as well

func (*SDLChunk) GetTextWithoutComments

func (c *SDLChunk) GetTextWithoutComments() string

GetTextWithoutComments extracts text excluding COMMENT ON statements This is used for comparing object definitions without considering comments

type SDLChunks

type SDLChunks struct {
	Tables            map[string]*SDLChunk // key: table name/identifier
	Views             map[string]*SDLChunk // key: view name/identifier
	MaterializedViews map[string]*SDLChunk // key: materialized view name/identifier
	Functions         map[string]*SDLChunk // key: function name/identifier
	Triggers          map[string]*SDLChunk // key: schema.table.trigger_name (table-scoped)
	Indexes           map[string]*SDLChunk // key: index name/identifier
	Sequences         map[string]*SDLChunk // key: sequence name/identifier
	Schemas           map[string]*SDLChunk // key: schema name/identifier
	EnumTypes         map[string]*SDLChunk // key: enum type name/identifier
	Extensions        map[string]*SDLChunk // key: extension name/identifier
	EventTriggers     map[string]*SDLChunk // key: event trigger name (database-level, no schema)

	// Column comments: map[schemaName.tableName][columnName] -> COMMENT ON COLUMN AST node
	ColumnComments map[string]map[string]antlr.ParserRuleContext

	// Index comments for table-level indexes: map[schemaName.tableName][indexName] -> COMMENT ON INDEX AST node
	IndexComments map[string]map[string]antlr.ParserRuleContext
}

type SDLDiff

type SDLDiff struct {
	CurrentChunks  *SDLChunks
	PreviousChunks *SDLChunks
	Added          []*SDLChunk
	Removed        []*SDLChunk
	Modified       []*SDLChunk
}

type SchemaDiff

type SchemaDiff struct {
	Action     MetadataDiffAction
	SchemaName string
	OldSchema  *storepb.SchemaMetadata
	NewSchema  *storepb.SchemaMetadata
}

nolint SchemaDiff represents changes to a schema.

type SequenceDiff

type SequenceDiff struct {
	Action       MetadataDiffAction
	SchemaName   string
	SequenceName string
	OldSequence  *storepb.SequenceMetadata
	NewSequence  *storepb.SequenceMetadata
	OldASTNode   any // AST node for old sequence
	NewASTNode   any // AST node for new sequence
}

SequenceDiff represents changes to a sequence.

type TableDiff

type TableDiff struct {
	Action     MetadataDiffAction
	SchemaName string
	TableName  string
	OldTable   *storepb.TableMetadata
	NewTable   *storepb.TableMetadata

	// AST nodes for DDL analysis and generation
	OldASTNode *parser.CreatestmtContext // Previous user CREATE TABLE AST node
	NewASTNode *parser.CreatestmtContext // Current user CREATE TABLE AST node

	// Column changes
	ColumnChanges []*ColumnDiff

	// Index changes (excluding PK and UK which are handled separately)
	IndexChanges []*IndexDiff

	// Primary key changes
	PrimaryKeyChanges []*PrimaryKeyDiff

	// Unique constraint changes
	UniqueConstraintChanges []*UniqueConstraintDiff

	// Foreign key changes
	ForeignKeyChanges []*ForeignKeyDiff

	// Check constraint changes
	CheckConstraintChanges []*CheckConstraintDiff

	// EXCLUDE constraint changes (PostgreSQL specific)
	ExcludeConstraintChanges []*ExcludeConstraintDiff

	// Partition changes
	PartitionChanges []*PartitionDiff

	// Trigger changes
	TriggerChanges []*TriggerDiff
}

TableDiff represents changes to a table.

type TriggerDiff

type TriggerDiff struct {
	Action      MetadataDiffAction
	SchemaName  string // Schema name of the table that owns the trigger
	TableName   string // Table name that owns the trigger
	TriggerName string // Trigger name
	OldTrigger  *storepb.TriggerMetadata
	NewTrigger  *storepb.TriggerMetadata
	OldASTNode  any // AST node for old trigger (*parser.CreatetrigstmtContext)
	NewASTNode  any // AST node for new trigger (*parser.CreatetrigstmtContext)
}

TriggerDiff represents changes to a trigger.

type UniqueConstraintDiff

type UniqueConstraintDiff struct {
	Action              MetadataDiffAction
	OldUniqueConstraint *storepb.IndexMetadata
	NewUniqueConstraint *storepb.IndexMetadata
	OldASTNode          any // AST node for old unique constraint
	NewASTNode          any // AST node for new unique constraint
}

UniqueConstraintDiff represents changes to a unique constraint.

type ViewChange

type ViewChange struct {
	Type        ViewChangeType
	Description string
	// RequiresRecreation indicates if the change requires dropping and recreating the view.
	RequiresRecreation bool
}

ViewChange represents a detected change in a view.

type ViewChangeType

type ViewChangeType int

ViewChangeType represents the type of change detected in a view.

const (
	// ViewChangeNone indicates no change.
	ViewChangeNone ViewChangeType = iota
	// ViewChangeDefinition indicates the view definition has changed.
	ViewChangeDefinition
	// ViewChangeComment indicates only the comment has changed.
	ViewChangeComment
	// ViewChangeColumn indicates column metadata has changed.
	ViewChangeColumn
	// ViewChangeTrigger indicates triggers have changed.
	ViewChangeTrigger
	// ViewChangeOther indicates other metadata changes.
	ViewChangeOther
)

type ViewComparer

type ViewComparer interface {
	// CompareView compares two views and returns the detected changes.
	CompareView(oldView, newView *storepb.ViewMetadata) ([]ViewChange, error)

	// CompareMaterializedView compares two materialized views and returns the detected changes.
	CompareMaterializedView(oldMV, newMV *storepb.MaterializedViewMetadata) ([]MaterializedViewChange, error)
}

ViewComparer provides engine-specific view comparison logic.

func GetViewComparer

func GetViewComparer(engine storepb.Engine) ViewComparer

GetViewComparer returns the view comparer for a specific engine. If no engine-specific comparer is registered, it returns the default comparer.

type ViewDiff

type ViewDiff struct {
	Action     MetadataDiffAction
	SchemaName string
	ViewName   string
	OldView    *storepb.ViewMetadata
	NewView    *storepb.ViewMetadata
	OldASTNode any // AST node for old view
	NewASTNode any // AST node for new view
}

ViewDiff represents changes to a view.

Directories

Path Synopsis
pg
ast

Jump to

Keyboard shortcuts

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