db

package
v0.0.2-RC2 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2023 License: GPL-3.0 Imports: 8 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// StateMigrationName is the name of the migration used by packr to pack the migration file
	StateMigrationName = "zkevm-state-db"
	// PoolMigrationName is the name of the migration used by packr to pack the migration file
	PoolMigrationName = "zkevm-pool-db"
)

Variables

This section is empty.

Functions

func CheckMigrations

func CheckMigrations(cfg Config, name string) error

CheckMigrations runs migrate-up for the given config.

func NewSQLDB

func NewSQLDB(cfg Config) (*pgxpool.Pool, error)

NewSQLDB creates a new SQL DB

func RunMigrationsDown

func RunMigrationsDown(cfg Config, name string) error

RunMigrationsDown runs migrate-down for the given config.

func RunMigrationsUp

func RunMigrationsUp(cfg Config, name string) error

RunMigrationsUp runs migrate-up for the given config.

Types

type Config

type Config struct {
	// Database name
	Name string `mapstructure:"Name"`

	// User name
	User string `mapstructure:"User"`

	// Password of the user
	Password string `mapstructure:"Password"`

	// Host address
	Host string `mapstructure:"Host"`

	// Port Number
	Port string `mapstructure:"Port"`

	// EnableLog
	EnableLog bool `mapstructure:"EnableLog"`

	// MaxConns is the maximum number of connections in the pool.
	MaxConns int `mapstructure:"MaxConns"`
}

Config provide fields to configure the pool

Jump to

Keyboard shortcuts

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