dbmigrator

package
v1.16.12-beta021 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package dbmigrator is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database interface {
	RunCommands(ctx context.Context, commands []bson.D) error
	InsertMigrationState(ctx context.Context, migration *DbMigration) error
	DeleteMigrationState(ctx context.Context, migration *DbMigration) error
	GetAppliedMigrations(ctx context.Context) ([]DbMigration, error)
}

func NewDatabase

func NewDatabase(db *mongo.Database, migrationsColl string) Database

TODO: Consider locks

type DbMigration

type DbMigration struct {
	Name       string   `bson:"name"`
	UpScript   []bson.D `bson:"up"`
	DownScript []bson.D `bson:"down"`
}

func GetDbMigrationsFromFs

func GetDbMigrationsFromFs(fsys fs.FS) ([]DbMigration, error)

type DbMigrator

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

func NewDbMigrator

func NewDbMigrator(db Database, list []DbMigration) *DbMigrator

func (*DbMigrator) Apply

func (d *DbMigrator) Apply(ctx context.Context) error

func (*DbMigrator) GetApplied

func (d *DbMigrator) GetApplied(ctx context.Context) (results []DbMigration, err error)

func (*DbMigrator) Plan

func (d *DbMigrator) Plan(ctx context.Context) (plan DbPlan, err error)

type DbPlan

type DbPlan struct {
	Ups   []DbMigration
	Downs []DbMigration
	Total int
}

type MockDatabase

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

MockDatabase is a mock of Database interface.

func NewMockDatabase

func NewMockDatabase(ctrl *gomock.Controller) *MockDatabase

NewMockDatabase creates a new mock instance.

func (*MockDatabase) DeleteMigrationState

func (m *MockDatabase) DeleteMigrationState(arg0 context.Context, arg1 *DbMigration) error

DeleteMigrationState mocks base method.

func (*MockDatabase) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockDatabase) GetAppliedMigrations

func (m *MockDatabase) GetAppliedMigrations(arg0 context.Context) ([]DbMigration, error)

GetAppliedMigrations mocks base method.

func (*MockDatabase) InsertMigrationState

func (m *MockDatabase) InsertMigrationState(arg0 context.Context, arg1 *DbMigration) error

InsertMigrationState mocks base method.

func (*MockDatabase) RunCommands

func (m *MockDatabase) RunCommands(arg0 context.Context, arg1 []primitive.D) error

RunCommands mocks base method.

type MockDatabaseMockRecorder

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

MockDatabaseMockRecorder is the mock recorder for MockDatabase.

func (*MockDatabaseMockRecorder) DeleteMigrationState

func (mr *MockDatabaseMockRecorder) DeleteMigrationState(arg0, arg1 interface{}) *gomock.Call

DeleteMigrationState indicates an expected call of DeleteMigrationState.

func (*MockDatabaseMockRecorder) GetAppliedMigrations

func (mr *MockDatabaseMockRecorder) GetAppliedMigrations(arg0 interface{}) *gomock.Call

GetAppliedMigrations indicates an expected call of GetAppliedMigrations.

func (*MockDatabaseMockRecorder) InsertMigrationState

func (mr *MockDatabaseMockRecorder) InsertMigrationState(arg0, arg1 interface{}) *gomock.Call

InsertMigrationState indicates an expected call of InsertMigrationState.

func (*MockDatabaseMockRecorder) RunCommands

func (mr *MockDatabaseMockRecorder) RunCommands(arg0, arg1 interface{}) *gomock.Call

RunCommands indicates an expected call of RunCommands.

Jump to

Keyboard shortcuts

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