# README
Migrator
The Migrator is a tool to execute schema migrations of dynamodb tables.
Requirements
The Migrator tool requires on a dedicated Metadata dynamodb table. The migration tool should have the following permissions on the migration metadata table :
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
Examples
Execute a schema migration
const migrationMetadataTable = "migrationMetadata"
func ExecuteMigrations(ctx context.Context, client *dynamodb.Client) error {
migrator := migrator.NewMigrator(migrationMetadataTable, 0, migrator.Migration{
Name: "InitialMigration",
Description: "Initial migration",
MigratorFn: func(_ context.Context, _ migrator.DynamoDBClient) error {
return nil
}
},
migrator.Must(migrator.NewScanAndUpdateMigration("SecondMigration", "Second migration", "tableToMigrate",
func(ctx context.Context, item map[string]types.AttributeValue) *dynamodb.UpdateItemInput) {
//implement the migration for an attribute here
}
),
}
return migrator.Execute(ctx, client)
# Packages
No description provided by the author
# Functions
No description provided by the author
NewMigrator creates a new Migrator that can execute a migration.
NewScanAndUpdateMigration create a migration that will execute a scan.
ScanAndUpdateMigrationWithConsistentRead annotate consistentRead on ScanAndUpdateMigration.
ScanAndUpdateMigrationWithFilterExpression set filter condition on ScanAndUpdateMigration.
ScanAndUpdateMigrationWithMetadata add metadata to ScanAndUpdateMigration.
# Structs
Migration to execute.
No description provided by the author
No description provided by the author
# Interfaces
go:generate go run github.com/vektra/mockery/v2 --name=DynamodbClient --with-expecter.
# Type aliases
No description provided by the author