Documentation
¶
Index ¶
- type DynamoDBClient
- type Option
- type Target
- func (t *Target) Add(ctx context.Context, id string) error
- func (t *Target) Create(ctx context.Context) error
- func (t *Target) Current(ctx context.Context) (string, error)
- func (t *Target) Destroy(ctx context.Context) error
- func (t *Target) Done(ctx context.Context) ([]string, error)
- func (t *Target) FinishMigration(ctx context.Context, id string) error
- func (t *Target) Lock(ctx context.Context) (migrations.Unlocker, error)
- func (t *Target) Remove(ctx context.Context, id string) error
- func (t *Target) StartMigration(ctx context.Context, id string) error
- type UnlockDynamoDBClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DynamoDBClient ¶
type DynamoDBClient interface { Scan(ctx context.Context, input *dynamodb.ScanInput, optFns ...func(*dynamodb.Options)) (*dynamodb.ScanOutput, error) PutItem(ctx context.Context, input *dynamodb.PutItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.PutItemOutput, error) DeleteItem(ctx context.Context, input *dynamodb.DeleteItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.DeleteItemOutput, error) UpdateItem(ctx context.Context, input *dynamodb.UpdateItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.UpdateItemOutput, error) CreateTable(ctx context.Context, input *dynamodb.CreateTableInput, optFns ...func(*dynamodb.Options)) (*dynamodb.CreateTableOutput, error) DeleteTable(ctx context.Context, input *dynamodb.DeleteTableInput, optFns ...func(*dynamodb.Options)) (*dynamodb.DeleteTableOutput, error) ListTables(ctx context.Context, d *dynamodb.ListTablesInput, optFns ...func(*dynamodb.Options)) (*dynamodb.ListTablesOutput, error) }
type Option ¶
type Option func(*opts)
func WithLockID ¶
WithLockID sets the lock ID to be used by the DynamoDB lock.
func WithLockTableName ¶
WithLockTableName sets the lock table name to be used by the DynamoDB lock.
func WithTableName ¶
WithTableName sets the table name to record the database migrations ran.
type Target ¶
type Target struct {
// contains filtered or unexported fields
}
func NewTarget ¶
func NewTarget(client DynamoDBClient, opts ...Option) *Target
func (*Target) Create ¶
Create will create the migrations table and the migrations lock table in the DynamoDB.
func (*Target) Current ¶
Current will return the current migration ID. If there is no current migration, it will return a migrations.ErrNoCurrentMigration error. Also, this implementation uses Done, so all errors Done would return can be returned by this method.
func (*Target) Destroy ¶
Destroy will delete the migrations table and the migrations lock table in the DynamoDB.
func (*Target) Done ¶
Done will list all migrations IDs done in the target. If a dirty migration is found, it will return an `migrations.ErrDirtyMigration`. The result will sorted by ID.
func (*Target) FinishMigration ¶
FinishMigration will mark a migration as finished (dirty = false). If the migration does not exist, it will return an `migrations.ErrMigrationNotFound`.
type UnlockDynamoDBClient ¶
type UnlockDynamoDBClient interface {
DeleteItem(ctx context.Context, params *dynamodb.DeleteItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.DeleteItemOutput, error)
}