db

package
v0.0.0-...-fc03dd6 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const MigrationsTable = "schema_migrations"

MigrationsTable table created by migration lib to track state of migration

Variables

This section is empty.

Functions

func NewPgxPool

func NewPgxPool(ctx context.Context, cfg PgConfig) (*pgxpool.Pool, error)

NewPgxPool get a concurrency safe pool of connection

func StartMigration

func StartMigration(pgc PgConfig, source source.Driver) error

StartMigration starts migration for alarms server from a k8s job.

Types

type MigrationConfig

type MigrationConfig struct {
	Host            string
	Port            string
	User            string
	Password        string
	Database        string
	MigrationsTable string
	Source          source.Driver
}

MigrationConfig PG config for migration

func PGtoMigrateConfig

func PGtoMigrateConfig(pgc PgConfig, source source.Driver) MigrationConfig

PGtoMigrateConfig convert postgres conn config to migration conn config

type MigrationHandler

type MigrationHandler struct {
	Migrate *migrate.Migrate
}

func NewHandler

func NewHandler(cfg MigrationConfig) (*MigrationHandler, error)

NewHandler configure the migration data

func (*MigrationHandler) Printf

func (h *MigrationHandler) Printf(format string, v ...interface{})

Printf is the implementation of migrate lib's logger interface

func (*MigrationHandler) Verbose

func (h *MigrationHandler) Verbose() bool

Verbose is the implementation of migrate lib's logger interface

type Model

type Model interface {
	PrimaryKey() string
	TableName() string
	OnConflict() string
}

type PgConfig

type PgConfig struct {
	Host     string
	Port     string
	User     string
	Password string
	Database string
}

func GetPgConfig

func GetPgConfig(username, password, database string) PgConfig

GetPgConfig common postgres config for alarms server

Jump to

Keyboard shortcuts

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