migrate

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const DynamoDB = "AWS::DynamoDB::Table"
View Source
const MigrationTable = "dynamo_migrations"

Variables

Functions

func SaveRecord

func SaveRecord(ctx context.Context, api MigrationApi, tableName string, record map[string]interface{}) (err error)

Types

type Attribute

type Attribute struct {
	Type types.ScalarAttributeType `json:"AttributeType" yaml:"AttributeType"`
	Name string                    `json:"AttributeName" yaml:"AttributeName"`
}

func (Attribute) Definition

func (attr Attribute) Definition() types.AttributeDefinition

type Attributes

type Attributes []Attribute

func (Attributes) Definitions

func (attrs Attributes) Definitions() []types.AttributeDefinition

func (Attributes) Map

func (attrs Attributes) Map() map[string]types.ScalarAttributeType

type FilesMigrate

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

func (*FilesMigrate) Run

func (v *FilesMigrate) Run(ctx context.Context, save SaveFunc) (err error)

type KeySchema

type KeySchema struct {
	Type types.KeyType `json:"KeyType" yaml:"KeyType"`
	Name string        `json:"AttributeName" yaml:"AttributeName"`
}

func (KeySchema) Element

func (k KeySchema) Element() *types.KeySchemaElement

type Keys

type Keys []KeySchema

func (Keys) Elements

func (keys Keys) Elements() []types.KeySchemaElement

func (Keys) Map

func (keys Keys) Map() map[string]types.KeyType

type Migrate

type Migrate interface {
	Run(ctx context.Context, save SaveFunc) error
}

func New

func New(api MigrationApi, dirPath ...string) Migrate

func Parse

func Parse(api MigrationApi, schema string) Migrate

type Migration

type Migration struct {
	ID string `json:"id" yaml:"id" dynamodbav:"id"`
}

type MigrationApi

type MigrationApi interface {
	DescribeTable(ctx context.Context, params *dynamodb.DescribeTableInput, optFns ...func(*dynamodb.Options)) (*dynamodb.DescribeTableOutput, error)
	CreateTable(ctx context.Context, params *dynamodb.CreateTableInput, optFns ...func(*dynamodb.Options)) (*dynamodb.CreateTableOutput, error)
	UpdateTimeToLive(ctx context.Context, params *dynamodb.UpdateTimeToLiveInput, optFns ...func(*dynamodb.Options)) (*dynamodb.UpdateTimeToLiveOutput, error)
	UpdateTable(ctx context.Context, params *dynamodb.UpdateTableInput, optFns ...func(*dynamodb.Options)) (*dynamodb.UpdateTableOutput, error)
	DescribeTimeToLive(ctx context.Context, params *dynamodb.DescribeTimeToLiveInput, optFns ...func(*dynamodb.Options)) (*dynamodb.DescribeTimeToLiveOutput, error)
	DeleteTable(ctx context.Context, params *dynamodb.DeleteTableInput, optFns ...func(*dynamodb.Options)) (*dynamodb.DeleteTableOutput, error)

	GetItem(ctx context.Context, params *dynamodb.GetItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.GetItemOutput, error)
	PutItem(ctx context.Context, params *dynamodb.PutItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.PutItemOutput, error)
}

type Projection

type Projection struct {
	Type           types.ProjectionType `json:"ProjectionType" yaml:"ProjectionType"`
	AttributeNames []string             `json:"NonKeyAttributes" yaml:"NonKeyAttributes"`
}

func (Projection) Element

func (p Projection) Element() *types.Projection

type ProvisionedThroughput

type ProvisionedThroughput struct {
	Read  int64 `json:"ReadCapacityUnits" yaml:"ReadCapacityUnits"`
	Write int64 `json:"WriteCapacityUnits" yaml:"WriteCapacityUnits"`
}

func (ProvisionedThroughput) Element

func (ProvisionedThroughput) Update

type Resource

type Resource struct {
	Type       string      `json:"Type" yaml:"Type"`
	Properties TableSchema `json:"Properties" yaml:"Properties"`
}

func (*Resource) Checksum

func (r *Resource) Checksum() (h [32]byte, err error)

type Resources

type Resources map[string]Resource

type SaveFunc

type SaveFunc func(ctx context.Context, api MigrationApi, tableName string, record map[string]interface{}) error

type Schema

type Schema struct {
	Table   TableSchema              `json:"schema" yaml:"schema"`
	Records []map[string]interface{} `json:"records" yaml:"records"`
	// contains filtered or unexported fields
}

func ParseJson

func ParseJson(name string, body []byte) (schemas []Schema, err error)

func ParseYaml

func ParseYaml(name string, body []byte) (schemas []Schema, err error)

type SchemaMigrate

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

func (*SchemaMigrate) Run

func (v *SchemaMigrate) Run(ctx context.Context, save SaveFunc) (err error)

type SecondaryIndex

type SecondaryIndex struct {
	Name       string                 `json:"IndexName" yaml:"IndexName"`
	Keys       Keys                   `json:"KeySchema" yaml:"KeySchema"`
	Projection *Projection            `json:"Projection" yaml:"Projection"`
	Throughput *ProvisionedThroughput `json:"ProvisionedThroughput,omitempty" yaml:"ProvisionedThroughput,omitempty"`
}

func (SecondaryIndex) CreateGlobal

func (s SecondaryIndex) CreateGlobal() types.GlobalSecondaryIndex

func (SecondaryIndex) CreateLocal

func (s SecondaryIndex) CreateLocal() types.LocalSecondaryIndex

type SecondaryIndexes

type SecondaryIndexes []SecondaryIndex

func (SecondaryIndexes) GlobalIndexes

func (indexes SecondaryIndexes) GlobalIndexes() []types.GlobalSecondaryIndex

func (SecondaryIndexes) LocalIndexes

func (indexes SecondaryIndexes) LocalIndexes() []types.LocalSecondaryIndex

func (SecondaryIndexes) UpdateGlobals

type TableSchema

type TableSchema struct {
	TableName            string                   `json:"TableName" yaml:"TableName"`
	Attributes           Attributes               `json:"AttributeDefinitions" yaml:"AttributeDefinitions"`
	Keys                 Keys                     `json:"KeySchema" yaml:"KeySchema"`
	Throughput           ProvisionedThroughput    `json:"ProvisionedThroughput" yaml:"ProvisionedThroughput"`
	BillingMode          types.BillingMode        `json:"BillingMode" yaml:"BillingMode"`
	GlobalSecondaryIndex SecondaryIndexes         `json:"GlobalSecondaryIndexes,omitempty" yaml:"GlobalSecondaryIndexes,omitempty"`
	LocalSecondaryIndex  SecondaryIndexes         `json:"LocalSecondaryIndexes,omitempty" yaml:"LocalSecondaryIndexes,omitempty"`
	TableClass           types.TableClass         `json:"TableClass" yaml:"TableClass"`
	TimeToLive           *TimeToLiveSpecification `json:"TimeToLiveSpecification,omitempty" yaml:"TimeToLiveSpecification,omitempty"`
}

func (TableSchema) Create

func (t TableSchema) Create(ctx context.Context, api MigrationApi) (out *dynamodb.CreateTableOutput, err error)

func (TableSchema) Delete

func (t TableSchema) Delete(ctx context.Context, api MigrationApi) (out *dynamodb.DeleteTableOutput, err error)

func (TableSchema) Exists

func (t TableSchema) Exists(ctx context.Context, api MigrationApi) (out *dynamodb.DescribeTableOutput, err error)

func (TableSchema) Update

type Template

type Template struct {
	Version   string `json:"AWSTemplateFormatVersion" yaml:"AWSTemplateFormatVersion"`
	Resources `json:"Resources" yaml:"Resources"`
}

type TimeToLiveSpecification

type TimeToLiveSpecification struct {
	AttributeName string `json:"AttributeName" yaml:"AttributeName"`
	Enabled       bool   `json:"Enabled" yaml:"Enabled"`
}

func (TimeToLiveSpecification) Element

Jump to

Keyboard shortcuts

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