sqlite

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package sqlite provides SQLite database infrastructure for Perles. It handles connection lifecycle, migrations, and repository implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

DB manages the SQLite database connection for Perles. It provides connection lifecycle management, automatic migrations, and access to repository implementations.

func NewDB

func NewDB(path string) (*DB, error)

NewDB opens a database connection, configures pragmas, and runs migrations. Creates the parent directory if it doesn't exist. If an existing database file is present, creates a backup at {path}.bak before running migrations.

Example:

db, err := sqlite.NewDB("~/.perles/perles.db")
if err != nil {
    return err
}
defer db.Close()

func (*DB) Close

func (db *DB) Close() error

Close releases database resources.

func (*DB) Connection

func (db *DB) Connection() *sql.DB

Connection returns the underlying *sql.DB for testing purposes.

func (*DB) SessionRepository

func (db *DB) SessionRepository() domain.SessionRepository

SessionRepository returns a SessionRepository instance using this connection. The repository implementation is in session_repository.go.

type SessionModel

type SessionModel struct {
	ID         int64
	GUID       string
	Project    string
	Name       *string // nullable
	State      string
	TemplateID *string // nullable
	EpicID     *string // nullable
	WorkDir    *string // nullable
	Labels     *string // nullable, JSON encoded

	// Worktree configuration
	WorktreeEnabled    bool
	WorktreeMode       string
	WorktreeBaseBranch *string // nullable
	WorktreeBranchName *string // nullable

	// Worktree state
	WorktreePath   *string // nullable
	WorktreeBranch *string // nullable

	// Session storage path
	SessionDir *string // nullable

	// Ownership
	OwnerCreatedPID *int64 // nullable
	OwnerCurrentPID *int64 // nullable

	// Metrics
	TokensUsed    int64
	ActiveWorkers int

	// Health tracking
	LastHeartbeatAt *int64 // Unix timestamp, nullable
	LastProgressAt  *int64 // Unix timestamp, nullable

	// Timestamps
	CreatedAt   int64  // Unix timestamp
	StartedAt   *int64 // Unix timestamp, nullable
	PausedAt    *int64 // Unix timestamp, nullable
	CompletedAt *int64 // Unix timestamp, nullable
	UpdatedAt   int64  // Unix timestamp
	ArchivedAt  *int64 // Unix timestamp, nullable
	DeletedAt   *int64 // Unix timestamp, nullable
}

SessionModel represents the database row for the sessions table. Fields map directly to SQL columns with Unix timestamps for time values.

Jump to

Keyboard shortcuts

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