storage

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: MIT Imports: 13 Imported by: 2

Documentation

Overview

Package storage creates a database connection and runs the migrations located in the `db/migrations` directory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectToDatabase

func ConnectToDatabase(ctx context.Context, config *DatabaseConfig) *pgxpool.Pool

ConnectToDatabase returns a connection pool, which can be used to execute queries to the database.

func DuplicateConstraintViolation

func DuplicateConstraintViolation(err error) bool

DuplicateConstraintViolation returns true if the errors represents a duplicate constraint violation (SQLSTATE 23505) occurred in the database.

func RunMigrations

func RunMigrations(config *DatabaseConfig, migrationsRepo string)

RunMigrations either from source code on a local machine if available (for developers) or from a GitHub repository (for production).

Types

type DatabaseConfig

type DatabaseConfig struct {
	// contains filtered or unexported fields
}

func NewDatabaseConfig

func NewDatabaseConfig(host, port, username, password, dbName string) *DatabaseConfig

Jump to

Keyboard shortcuts

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