postgres

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

internal/services/postgres/client.go

internal/services/postgres/migrations.go

internal/services/postgres/postgres.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client provides database operations

func NewClient

func NewClient(service *Service) *Client

NewClient creates a new database client

func (*Client) Backup

func (c *Client) Backup(outputPath string) error

Backup creates a database backup

func (*Client) Connect

func (c *Client) Connect() error

Connect opens an interactive psql session

func (*Client) Exec

func (c *Client) Exec(query string, args ...interface{}) (sql.Result, error)

Exec executes a statement

func (*Client) ExecuteFile

func (c *Client) ExecuteFile(filePath string) error

ExecuteFile executes a SQL file

func (*Client) Query

func (c *Client) Query(query string, args ...interface{}) (*sql.Rows, error)

Query executes a query and returns results

func (*Client) QueryRow

func (c *Client) QueryRow(query string, args ...interface{}) *sql.Row

func (*Client) Restore

func (c *Client) Restore(inputPath string) error

Restore restores a database backup

func (*Client) Transaction

func (c *Client) Transaction() (*sql.Tx, error)

Transaction starts a new transaction

type Migration

type Migration struct {
	Version   int
	Name      string
	SQL       string
	Timestamp time.Time
}

Migration represents a database migration

type MigrationManager

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

MigrationManager handles database migrations

func NewMigrationManager

func NewMigrationManager(client *Client) *MigrationManager

NewMigrationManager creates a new migration manager

func (*MigrationManager) Initialize

func (m *MigrationManager) Initialize() error

Initialize creates the migration tracking table

func (*MigrationManager) Migrate

func (m *MigrationManager) Migrate(migrationsPath string) error

Migrate runs all pending migrations

func (*MigrationManager) Status

func (m *MigrationManager) Status() error

Status shows migration status

type Service

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

Service represents PostgreSQL service

func NewService

func NewService(cfg *config.DatabaseConfig) *Service

NewService creates a new PostgreSQL service

func (*Service) Close

func (s *Service) Close() error

Close closes the database connection

func (*Service) GetConnectionString

func (s *Service) GetConnectionString() string

GetConnectionString returns the connection string

func (*Service) GetDB

func (s *Service) GetDB() *sql.DB

GetDB returns the database connection

func (*Service) HasExtension

func (s *Service) HasExtension(name string) bool

HasExtension checks if an extension is available

func (*Service) Initialize

func (s *Service) Initialize() error

Initialize initializes the PostgreSQL service

Jump to

Keyboard shortcuts

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