postgres

package
v0.0.0-...-5ff842d Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(sugar *zap.SugaredLogger, url string) *pgx.Conn

func RunMigrations

func RunMigrations(conn *pgx.Conn, sugar *zap.SugaredLogger) error

RunMigrations ensures all the defined migrations have been run against the given pg connection - Creates the migrations table if needed - Finds any existing migrations - Runs any migrations which are missing, updating the migrations table

This function is idempotent, subsequent calls against the same connection are safe.

Types

type Migration

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

A migration represents a one-time SQL query that is run on application startup to alter the schema of the database. On application start, we check for un-executed migrations and run them one at a time. This ensures our database schema matches our code.

Once a migration has been defined, it should never be deleted to preserve compatiblity with any systems which have applied that migration. Instead, just append a new migration to the list.

Jump to

Keyboard shortcuts

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