db

package
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AggregatorMigrationName is the name of the migration used to associate with the migrations dir
	AggregatorMigrationName = "zkevm-aggregator-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(logger *log.Logger, 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