db

package
v0.2.0-RC6 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: AGPL-3.0, AGPL-3.0-or-later 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"`

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

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

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

	// Port Number of database
	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