Documentation
¶
Overview ¶
Package database provides functions to migrate the database.
Index ¶
- Constants
- func GetMigrate(connString string) (*migrate.Migrate, error)
- func GetPrimeTemplate() ([]byte, error)
- func GetVersion(connString string) (uint, bool, error)
- func MigrateDown(_ context.Context, db *pgx.Conn, steps int) error
- func MigrateUp(_ context.Context, db *pgx.Conn) error
- func RegisterEnumArrayCodecs(ctx context.Context, conn *pgx.Conn) error
- func SetupTestDB(t *testing.T) (*pgx.Conn, func())
- func SetupTestDBContainer(t *testing.T, ctx context.Context) (*pgx.Conn, func())
Constants ¶
const ( // DBName is the name of the test database. DBName = "testdb" // DBUser is the username for the root user of the test database. DBUser = "testuser" // DBPass is the password for the root user of the test database. DBPass = "testpass" )
Variables ¶
This section is empty.
Functions ¶
func GetMigrate ¶
GetMigrate creates a new migrate instance using the embedded migrations
func GetPrimeTemplate ¶ added in v0.3.0
GetPrimeTemplate returns the contents of the prime.sql.tmpl template file
func GetVersion ¶
GetVersion returns the current migration version
func MigrateDown ¶
MigrateDown reverts the last migration
func RegisterEnumArrayCodecs ¶ added in v1.4.6
RegisterEnumArrayCodecs registers pgx array codecs for the schema's custom enum types. It is the AfterConnect hook used by both the production connection pool and the test database setup, so both encode enum-array parameters identically.
The codecs are resolved from the live database — the enum OIDs are assigned at migration time — so this must run after migrations, on a connection that can read pg_type.
func SetupTestDB ¶
SetupTestDB returns an isolated, migrated database on a package-shared Postgres process.
Types ¶
This section is empty.