schema

package
v1.0.13 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TransformWithValidation

func TransformWithValidation(item map[string]types.AttributeValue, transform TransformFunc,
	sourceMetadata, targetMetadata *model.Metadata) (map[string]types.AttributeValue, error)

TransformWithValidation applies a transform with validation and error handling

Types

type AutoMigrateOption

type AutoMigrateOption func(*AutoMigrateOptions)

AutoMigrateOption is a function that configures AutoMigrateOptions

func WithBackupTable

func WithBackupTable(tableName string) AutoMigrateOption

WithBackupTable sets a backup table name

func WithBatchSize

func WithBatchSize(size int) AutoMigrateOption

WithBatchSize sets the batch size for data copy operations

func WithContext

func WithContext(ctx context.Context) AutoMigrateOption

WithContext sets the context for the operation

func WithDataCopy

func WithDataCopy(enable bool) AutoMigrateOption

WithDataCopy enables data copying

func WithTargetModel

func WithTargetModel(model any) AutoMigrateOption

WithTargetModel sets a different target model for migration

func WithTransform

func WithTransform(transform interface{}) AutoMigrateOption

WithTransform sets a transformation function for data migration

type AutoMigrateOptions

type AutoMigrateOptions struct {
	// BackupTable specifies a table name to backup data to before migration
	BackupTable string

	// DataCopy enables copying data from source to target table
	DataCopy bool

	// TargetModel specifies a different model to migrate data to
	TargetModel any

	// Transform is a function to transform data during copy
	Transform interface{}

	// BatchSize for data copy operations
	BatchSize int

	// Context for the operation
	Context context.Context
}

AutoMigrateOptions holds configuration for AutoMigrate operations

type GSIUpdatePlan

type GSIUpdatePlan struct {
	ToCreate []types.GlobalSecondaryIndex
	ToDelete []string
}

GSIUpdatePlan contains GSIs to create and delete

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles DynamoDB table schema operations

func NewManager

func NewManager(session *session.Session, registry *model.Registry) *Manager

NewManager creates a new schema manager

func (*Manager) AutoMigrateWithOptions

func (m *Manager) AutoMigrateWithOptions(sourceModel any, options ...AutoMigrateOption) error

AutoMigrateWithOptions performs an enhanced auto-migration with data copy support

func (*Manager) BatchUpdateTable

func (m *Manager) BatchUpdateTable(model any, updates []TableOption) error

BatchUpdateTable performs multiple table updates that require separate API calls This is useful for multiple GSI changes since DynamoDB only allows one GSI operation per UpdateTable call

func (*Manager) CreateTable

func (m *Manager) CreateTable(model any, opts ...TableOption) error

CreateTable creates a DynamoDB table based on the model struct

func (*Manager) DeleteTable

func (m *Manager) DeleteTable(tableName string) error

DeleteTable deletes a DynamoDB table

func (*Manager) DescribeTable

func (m *Manager) DescribeTable(model any) (*types.TableDescription, error)

DescribeTable returns table description

func (*Manager) TableExists

func (m *Manager) TableExists(tableName string) (bool, error)

TableExists checks if a table exists

func (*Manager) UpdateTable

func (m *Manager) UpdateTable(model any, opts ...TableOption) error

UpdateTable updates table configuration (throughput, indexes, etc.)

type ModelTransformFunc

type ModelTransformFunc interface{}

ModelTransformFunc defines a function that transforms between model types It takes a source model instance and returns a target model instance

type TableOption

type TableOption func(*dynamodb.CreateTableInput)

TableOption configures table creation options

func WithBillingMode

func WithBillingMode(mode types.BillingMode) TableOption

WithBillingMode sets the billing mode for the table

func WithGSICreate

func WithGSICreate(indexName string, partitionKey string, sortKey string, projectionType types.ProjectionType) TableOption

WithGSICreate creates a TableOption for adding a new GSI

func WithGSIDelete

func WithGSIDelete(indexName string) TableOption

WithGSIDelete creates a TableOption for deleting a GSI

func WithSSESpecification

func WithSSESpecification(spec types.SSESpecification) TableOption

WithSSESpecification enables server-side encryption

func WithStreamSpecification

func WithStreamSpecification(spec types.StreamSpecification) TableOption

WithStreamSpecification enables DynamoDB streams

func WithThroughput

func WithThroughput(rcu, wcu int64) TableOption

WithThroughput sets provisioned throughput for the table

type TransformFunc

type TransformFunc func(source map[string]types.AttributeValue) (map[string]types.AttributeValue, error)

TransformFunc defines a function that transforms data during migration It takes a source item and returns a transformed target item

func AddField

func AddField(fieldName string, defaultValue types.AttributeValue) TransformFunc

AddField creates a transform that adds a new field with a default value

func ChainTransforms

func ChainTransforms(transforms ...TransformFunc) TransformFunc

ChainTransforms combines multiple transforms into a single transform

func CopyAllFields

func CopyAllFields() TransformFunc

CopyAllFields creates a transform that copies all fields from source to target

func CreateModelTransform

func CreateModelTransform(transformFunc interface{}, sourceMetadata, targetMetadata *model.Metadata) (TransformFunc, error)

CreateModelTransform creates a transform function from a model-to-model function

func RemoveField

func RemoveField(fieldName string) TransformFunc

RemoveField creates a transform that removes a field

func RenameField

func RenameField(oldName, newName string) TransformFunc

RenameField creates a transform that renames a field

type TransformValidator

type TransformValidator struct {
	// contains filtered or unexported fields
}

TransformValidator validates transform operations

func NewTransformValidator

func NewTransformValidator(sourceMetadata, targetMetadata *model.Metadata) *TransformValidator

NewTransformValidator creates a new transform validator

func (*TransformValidator) ValidateTransform

func (v *TransformValidator) ValidateTransform(transform interface{}) error

ValidateTransform validates that a transform function is compatible with the source and target models

Jump to

Keyboard shortcuts

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