migration

package
v0.0.0-...-445d492 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitSchemas

func InitSchemas(ctx context.Context, to, from DBConn) (err error)

InitSchemas executes the DDL that initializes the schemas and tables that the different IM Operands will use.

func Migrate

func Migrate(ctx context.Context, c chan *Result, migrations ...*Migration)

Migrate initializes the EDB database for the IM Operands and performs any additional migrations that may be needed.

func MongoToV1

func MongoToV1(ctx context.Context, to, from DBConn) (err error)

Types

type DBConn

type DBConn interface {
	Connect(context.Context) error
	Configure(...DBOption) error
	RunDDL(context.Context, string) error
	HasSchemas(context.Context) (bool, error)
	Disconnect(context.Context) error
}

type DBOption

type DBOption func(*DBOptions) error

func Host

func Host(host string) DBOption

func ID

func ID(id string) DBOption

func Name

func Name(name string) DBOption

func Password

func Password(password string) DBOption

func Port

func Port(port string) DBOption

func Schemas

func Schemas(schemas ...string) DBOption

func TLSConfig

func TLSConfig(caCert, clientCert, clientKey []byte) DBOption

func User

func User(user string) DBOption

type DBOptions

type DBOptions struct {
	Name      string      // the name of the database used in a DSN
	ID        string      // the identifier used for logs, recording migration activity, etc.
	Port      string      // the port used to connect to
	User      string      // the user to authenticate as
	Password  string      // the password to authenticate with
	Host      string      // the database hostname/URL
	TLSConfig *tls.Config // the certificates used to authenticate with
	Schemas   []string    // a list of schema names
}

DBOptions repesent a series of details about a given database instance

func (*DBOptions) Configure

func (o *DBOptions) Configure(opts ...DBOption) (err error)

func (*DBOptions) GetMigrationKey

func (o *DBOptions) GetMigrationKey() string

GetMigrationKey returns a key name used for writing back successful migration state to some other database

type Migration

type Migration struct {
	Name string
	To   DBConn
	From DBConn
	// contains filtered or unexported fields
}

func (*Migration) Run

func (m *Migration) Run(ctx context.Context) (err error)

type MigrationBuilder

type MigrationBuilder struct {
	Migration *Migration
}

func NewMigration

func NewMigration() *MigrationBuilder

func (*MigrationBuilder) Build

func (m *MigrationBuilder) Build() *Migration

func (*MigrationBuilder) From

func (m *MigrationBuilder) From(from DBConn) *MigrationBuilder

func (*MigrationBuilder) Name

func (m *MigrationBuilder) Name(name string) *MigrationBuilder

func (*MigrationBuilder) RunFunc

func (*MigrationBuilder) To

type MongoDB

type MongoDB struct {
	*DBOptions
	Client *mongo.Client
}

func NewMongoDB

func NewMongoDB(opts ...DBOption) (m *MongoDB, err error)

func (*MongoDB) Connect

func (m *MongoDB) Connect(ctx context.Context) (err error)

func (*MongoDB) Disconnect

func (m *MongoDB) Disconnect(ctx context.Context) error

func (*MongoDB) HasSchemas

func (m *MongoDB) HasSchemas(ctx context.Context) (bool, error)

func (*MongoDB) RunDDL

func (m *MongoDB) RunDDL(ctx context.Context, ddl string) error

type PostgresDB

type PostgresDB struct {
	*DBOptions
	Conn *pgx.Conn
}

func NewPostgresDB

func NewPostgresDB(opts ...DBOption) (*PostgresDB, error)

func (*PostgresDB) Connect

func (p *PostgresDB) Connect(ctx context.Context) (err error)

func (*PostgresDB) Disconnect

func (p *PostgresDB) Disconnect(ctx context.Context) error

func (*PostgresDB) HasSchemas

func (p *PostgresDB) HasSchemas(ctx context.Context) (bool, error)

func (*PostgresDB) RunDDL

func (p *PostgresDB) RunDDL(ctx context.Context, ddl string) (err error)

type Result

type Result struct {
	Complete   []*Migration
	Incomplete []*Migration

	Error error
}

func (*Result) IsFailure

func (r *Result) IsFailure() bool

func (*Result) IsSuccess

func (r *Result) IsSuccess() bool

Directories

Path Synopsis
schema
v1

Jump to

Keyboard shortcuts

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