postgres

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

README

Users - DB Schema

CREATE TYPE user_status AS ENUM ('enabled', 'disabled');

CREATE TABLE IF NOT EXISTS users (
    id          UUID UNIQUE NOT NULL,
    email       VARCHAR(254) UNIQUE NOT NULL,
    password    CHAR(60) NOT NULL,
    metadata    JSONB,
    status      USER_STATUS NOT NULL DEFAULT 'enabled',
    PRIMARY KEY (id)
);

CREATE TABLE IF NOT EXISTS verifications (
    email      VARCHAR(254) NOT NULL,
    password   CHAR(60) NOT NULL,
    token      UUID UNIQUE NOT NULL,
    created_at TIMESTAMPTZ NOT NULL,
    expires_at TIMESTAMPTZ NOT NULL
);

CREATE TABLE IF NOT EXISTS platform_invites (
    id            UUID NOT NULL,
    invitee_email VARCHAR NOT NULL,
    created_at    TIMESTAMPTZ,
    expires_at    TIMESTAMPTZ,
    state         VARCHAR DEFAULT 'pending' NOT NULL
);

CREATE UNIQUE INDEX unique_invitee_email_pending on platform_invites (invitee_email) WHERE state='pending';

Documentation

Overview

Package postgres contains repository implementations using PostgreSQL as the underlying database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(cfg Config) (*sqlx.DB, error)

Connect creates a connection to the PostgreSQL instance and applies any unapplied database migrations. A non-nil error is returned to indicate failure.

func NewEmailVerificationRepo added in v0.29.0

func NewEmailVerificationRepo(db dbutil.Database) users.EmailVerificationRepository

func NewPlatformInvitesRepo added in v0.30.0

func NewPlatformInvitesRepo(db dbutil.Database) users.PlatformInvitesRepository

func NewUserRepo

func NewUserRepo(db dbutil.Database) users.UserRepository

NewUserRepo instantiates a PostgreSQL implementation of user repository.

Types

type Config

type Config struct {
	Host        string
	Port        string
	User        string
	Pass        string
	Name        string
	SSLMode     string
	SSLCert     string
	SSLKey      string
	SSLRootCert string
}

Config defines the options that are used when connecting to a PostgreSQL instance

Jump to

Keyboard shortcuts

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