psql

package
v0.0.0-...-f84185f Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// For gcp cloud postgres database
	GoogleProject     = "GOOGLE_CLOUD_PROJECT_ID"
	DatabaseRegion    = "DATABASE_REGION"
	DatabasesInstance = "DATABASE_INSTANCE"

	DBHost     = "POSTGRES_HOST"
	DBPort     = "POSTGRES_PORT"
	DBUser     = "POSTGRES_USER"
	DBPassword = "POSTGRES_PASSWORD"
	DBName     = "POSTGRES_DB"
)

Variables

This section is empty.

Functions

func RunMigrations

func RunMigrations() error

RunMigrations looks at the currently active migration version and will migrate all the way up (applying all up migrations)

Types

type Base

type Base struct {
	ID        *string    `gorm:"primaryKey;unique;column:id"`
	CreatedAt time.Time  `gorm:"column:created_at"`
	UpdatedAt time.Time  `gorm:"column:updated_at"`
	CreatedBy *string    `gorm:"column:created_by"`
	UpdatedBy *string    `gorm:"column:updated_by"`
	DeletedAt *time.Time `gorm:"column:deleted_at"`
	Active    bool       `gorm:"column:active"`
}

Base model contains defines common fields across tables

func (*Base) BeforeCreate

func (b *Base) BeforeCreate(tx *gorm.DB) (err error)

type BaseService

type BaseService struct {
	Base
	CommonModel

	BusinessProfile string     `json:"business_profile"`
	Services        []*Service `gorm:"ForeignKey:base_service;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
}

func (BaseService) TableName

func (BaseService) TableName() string

type BusinessPartner

type BusinessPartner struct {
	Base

	Name      string  `gorm:"column:name"`
	PartnerID *string `gorm:"column:partner_id"`
}

BusinessPartner models a business partner

func (BusinessPartner) TableName

func (BusinessPartner) TableName() string

type BusinessProfile

type BusinessProfile struct {
	Base

	Name           string `gorm:"column:name"`
	Description    string `gorm:"column:description"`
	IntroStatement string `gorm:"column:intro_statement"`
	Mission        string `gorm:"column:mission"`
	Vision         string `gorm:"column:vision"`
	Slogan         string `gorm:"column:slogan"`
	PhoneNumber    string `gorm:"column:phone_number"`
	Email          string `gorm:"column:email"`
	Facebook       string `gorm:"column:facebook"`
	X              string `gorm:"column:x"`
	Instagram      string `gorm:"column:instagram"`
	TikTok         string `gorm:"column:tiktok"`
	WhatsApp       string `gorm:"column:whats_app"`
	LinkedIn       string `gorm:"column:linkedin"`
	PostalAddress  string `gorm:"column:postal_address"`
	City           string `gorm:"column:city"`
	Country        string `gorm:"column:country"`
	Building       string `gorm:"column:building"`
	FloorNumber    string `gorm:"column:floor_number"`

	Partner    *Partner     `gorm:"ForeignKey:business_profile;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	Services   *BaseService `gorm:"ForeignKey:business_profile;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	Commitment *Commitment  `gorm:"ForeignKey:business_profile;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
}

func (BusinessProfile) TableName

func (BusinessProfile) TableName() string

type Commitment

type Commitment struct {
	Base
	CommonModel

	BusinessProfile string   `json:"business_profile"`
	WhyUs           []*WhyUs `gorm:"ForeignKey:commitment;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
}

func (Commitment) TableName

func (Commitment) TableName() string

type CommonModel

type CommonModel struct {
	Heading            string `gorm:"heading"`
	HeadingSupportText string `json:"heading_support_text" gorm:"heading_support_text"`
}

type Content

type Content struct {
	Base

	Title         string         `gorm:"column:title"`
	Description   string         `gorm:"column:description"`
	Body          string         `gorm:"column:body"`
	HeroImage     string         `gorm:"column:hero_image"`
	GalleryImages pq.StringArray `gorm:"type:text[];column:gallery_images"`
	Category      string         `gorm:"column:category"`
	Tags          pq.StringArray `gorm:"type:text[];column:tags"`
	ContentType   string         `gorm:"column:content_type"`
	Media         string         `gorm:"column:media"`
	Price         float64        `gorm:"column:price"`
	Story         *string        `gorm:"column:story_id"`
}

func (Content) TableName

func (Content) TableName() string

type PGInstance

type PGInstance struct {
	DB *gorm.DB
}

PGInstance box for postgres client. We use this instead of a global variable

func NewPGInstance

func NewPGInstance() (*PGInstance, error)

NewPGInstance creates a new instance of postgres client

func (*PGInstance) CreateUser

func (d *PGInstance) CreateUser(ctx context.Context, user *User) (*User, error)

CreateUser create a new user

type Partner

type Partner struct {
	Base
	CommonModel

	BusinessProfile  string             `json:"business_profile"`
	BusinessPartners []*BusinessPartner `gorm:"ForeignKey:PartnerID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
}

func (Partner) TableName

func (Partner) TableName() string

type Service

type Service struct {
	Base

	Title       string  `gorm:"title"`
	Description string  `gorm:"description"`
	BaseService *string `gorm:"base_service"`
}

Service models the available services

func (Service) TableName

func (Service) TableName() string

type Story

type Story struct {
	Base
	CommonModel

	BusinessProfile string     `json:"business_profile"`
	Content         []*Content `gorm:"ForeignKey:story_id;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
}

func (Story) TableName

func (Story) TableName() string

type Update

type Update interface {
}

Update holds all the database record update methods

type User

type User struct {
	Base

	Username  string `gorm:"column:username"`
	FirstName string `gorm:"column:first_name"`
	LastName  string `gorm:"column:last_name"`
	Email     string `gorm:"column:email"`
	UserType  string `gorm:"column:user_type"`
}

func (User) TableName

func (User) TableName() string

type UserCredentials

type UserCredentials struct {
	Base

	ValidFrom time.Time `gorm:"column:valid_from"`
	ValidTo   time.Time `gorm:"column:valid_to"`
	HashedPin string    `gorm:"column:hashed_pin"`
	Salt      string    `gorm:"column:salt"`
	UserID    *string   `gorm:"column:user_id"`
}

func (UserCredentials) TableName

func (UserCredentials) TableName() string

type WhyUs

type WhyUs struct {
	Base

	Title       string  `gorm:"title"`
	Description string  `gorm:"description"`
	Commitment  *string `gorm:"commitment"`
}

func (WhyUs) TableName

func (WhyUs) TableName() string

Jump to

Keyboard shortcuts

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