target

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database interface {
	DoMigrationTableExists(schema string) (bool, error)
	CreateMigrationTable(schema string) error
	GetMaxSequence(schema string) (int, error)
	GetLatestBatch(schema string) (string, error)
	InsertMigrationLog(schema string, version int, name string, batch string) error
	DeleteMigrationLog(schema string, batch string) error
	ExecuteMigration(schema string, command string) error
	GetSequenceByBatch(schema string, batch string) ([]int, error)
	DoesSchemaExists(schema string) (bool, error)
	CreateSchema(schema string) error
}

type DatabaseImplementation

type DatabaseImplementation struct {
	DB *sql.DB
	// contains filtered or unexported fields
}

DatabaseImplementation to access the database

func GetDatabase

func GetDatabase(dbURL string, isSSLRequred bool) (*DatabaseImplementation, error)

GetDatabase returns DB implementation

func (*DatabaseImplementation) CreateMigrationTable

func (base *DatabaseImplementation) CreateMigrationTable(schema string) error

CreateMigrationTable Create a migration table

func (*DatabaseImplementation) CreateSchema

func (base *DatabaseImplementation) CreateSchema(schema string) error

CreateSchema Create the schema

func (*DatabaseImplementation) DeleteMigrationLog

func (base *DatabaseImplementation) DeleteMigrationLog(schema string, batch string) error

DeleteMigrationLog Deletes a batch of migration logs

func (*DatabaseImplementation) DoMigrationTableExists

func (base *DatabaseImplementation) DoMigrationTableExists(schema string) (bool, error)

DoMigrationTableExists Check if migration table exsists

func (*DatabaseImplementation) DoesSchemaExists

func (base *DatabaseImplementation) DoesSchemaExists(schema string) (bool, error)

DoesSchemaExists Check if schema exists

func (*DatabaseImplementation) ExecuteMigration

func (base *DatabaseImplementation) ExecuteMigration(schema string, command string) error

ExecuteMigration executes the given SQL as script

func (*DatabaseImplementation) GetLatestBatch

func (base *DatabaseImplementation) GetLatestBatch(schema string) (string, error)

GetLatestBatch Gets the latest batch in the schema

func (*DatabaseImplementation) GetMaxSequence

func (base *DatabaseImplementation) GetMaxSequence(schema string) (int, error)

GetMaxSequence Gets the max sequence in the schema

func (*DatabaseImplementation) GetSequenceByBatch

func (base *DatabaseImplementation) GetSequenceByBatch(schema string, batch string) ([]int, error)

GetSequenceByBatch get the sequence ids by batch

func (*DatabaseImplementation) InsertMigrationLog

func (base *DatabaseImplementation) InsertMigrationLog(schema string, version int, name string, batch string) error

InsertMigrationLog inserts a migration log

type MigrationQueries

type MigrationQueries interface {
	CountMigrationTableSQL() string
	CreateMigrationTableSQL(schema string) string
	GetMaxSequenceSQL(schema string) string
	GetLatestBatchSQL(schema string) string
	InsertMigrationLogSQL(schema string) string
	DeleteMigrationLogSQL(schema string) string
	SetSchemaSQL(schema string) string
	GetSequenceByBatchSQL(schema string) string
	CountSchemaSQL() string
	CreateSchemaSQL(schema string) string
}

MigrationQueries interface to get all the required queries.

type Postgres

type Postgres struct{}

Postgres struct to return Postgres queries

func (Postgres) CountMigrationTableSQL

func (p Postgres) CountMigrationTableSQL() string

CountMigrationTableSQL query to check if migration table exists

func (Postgres) CountSchemaSQL

func (p Postgres) CountSchemaSQL() string

GetSequenceByBatchSQL query to return sequences by batch

func (Postgres) CreateMigrationTableSQL

func (p Postgres) CreateMigrationTableSQL(schema string) string

CreateMigrationTableSQL query to create migration table

func (Postgres) CreateSchemaSQL

func (p Postgres) CreateSchemaSQL(schema string) string

CreateSchemaSQL query to check if migration schema exists

func (Postgres) DeleteMigrationLogSQL

func (p Postgres) DeleteMigrationLogSQL(schema string) string

DeleteMigrationLogSQL query to delete migration

func (Postgres) GetLatestBatchSQL

func (p Postgres) GetLatestBatchSQL(schema string) string

GetLatestBatchSQL query to return latest batch name in the schema

func (Postgres) GetMaxSequenceSQL

func (p Postgres) GetMaxSequenceSQL(schema string) string

GetMaxSequenceSQL query to return Max sequence in the schema

func (Postgres) GetSequenceByBatchSQL

func (p Postgres) GetSequenceByBatchSQL(schema string) string

GetSequenceByBatchSQL query to return sequences by batch

func (Postgres) InsertMigrationLogSQL

func (p Postgres) InsertMigrationLogSQL(schema string) string

InsertMigrationLogSQL query to insert a migration

func (Postgres) SetSchemaSQL

func (p Postgres) SetSchemaSQL(schema string) string

SetSchemaSQL sets the schema to correct folder

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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