database

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTestDSN

func GetTestDSN() string

Types

type Artifact

type Artifact struct {
	ID          int64
	TenantID    string
	Container   string
	Name        string
	Size        int64
	ContentType string
	ETag        string
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

Artifact represents stored artifact metadata

type ChangeRecord

type ChangeRecord struct {
	ID        int64
	TenantID  string
	Container string
	Artifact  string
	Operation string
	Timestamp time.Time
}

type Config

type Config struct {
	Host     string
	Port     int
	Database string
	User     string
	Password string
	SSLMode  string
}

Config holds database configuration

type HistoryStore

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

func NewHistoryStore

func NewHistoryStore(db *sql.DB) *HistoryStore

func (*HistoryStore) GetHistory

func (h *HistoryStore) GetHistory(ctx context.Context, tenantID, container, artifact string) ([]ChangeRecord, error)

func (*HistoryStore) RecordChange

func (h *HistoryStore) RecordChange(ctx context.Context, tenantID, container, artifact, operation string) error

type Postgres

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

Postgres represents a PostgreSQL connection

func NewPostgres

func NewPostgres(cfg Config, logger *zap.Logger) (*Postgres, error)

NewPostgres creates a new PostgreSQL connection

func (*Postgres) Close

func (p *Postgres) Close() error

Close closes the database connection

func (*Postgres) CreateArtifact

func (p *Postgres) CreateArtifact(ctx context.Context, artifact *Artifact) error

CreateArtifact stores artifact metadata

func (*Postgres) CreateTables

func (p *Postgres) CreateTables(ctx context.Context) error

CreateTables creates the necessary database tables

func (*Postgres) CreateTenant

func (p *Postgres) CreateTenant(ctx context.Context, tenant *Tenant) error

CreateTenant creates a new tenant

func (*Postgres) DeleteArtifact

func (p *Postgres) DeleteArtifact(ctx context.Context, tenantID, container, name string) error

DeleteArtifact removes artifact metadata

func (*Postgres) GetArtifact

func (p *Postgres) GetArtifact(ctx context.Context, tenantID, container, name string) (*Artifact, error)

GetArtifact retrieves artifact metadata

func (*Postgres) GetTenant

func (p *Postgres) GetTenant(ctx context.Context, id string) (*Tenant, error)

GetTenant retrieves a tenant by ID

func (*Postgres) ListArtifacts

func (p *Postgres) ListArtifacts(ctx context.Context, tenantID, container string, limit int) ([]*Artifact, error)

ListArtifacts lists artifacts in a container

func (*Postgres) Ping

func (p *Postgres) Ping(ctx context.Context) error

Ping verifies the database connection

type Tenant

type Tenant struct {
	ID        string
	Name      string
	CreatedAt time.Time
	Email     string
}

Tenant represents a tenant in the system

Jump to

Keyboard shortcuts

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