database

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const SchemaReputationV2 = `` /* 8849-byte string literal not displayed */

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Path       string
	WALEnabled bool
}

Config holds database configuration

type DB

type DB struct {
	*sql.DB
	// contains filtered or unexported fields
}

DB wraps SQL database connection

func Factory

func Factory(cfg *config.Config, logger *zap.Logger) (*DB, error)

Factory creates a database connection based on driver configuration

func New

func New(cfg Config, logger *zap.Logger) (*DB, error)

New creates a new database connection

func (*DB) Analyze

func (db *DB) Analyze() error

Analyze updates database statistics

func (*DB) Close

func (db *DB) Close() error

Close closes the database connection

func (*DB) DriverType

func (db *DB) DriverType() Driver

func (*DB) Migrate

func (db *DB) Migrate() error

Migrate runs all pending migrations

func (*DB) Rollback

func (db *DB) Rollback(targetVersion int) error

Rollback rolls back to a specific version

func (*DB) Vacuum

func (db *DB) Vacuum() error

Vacuum performs database maintenance

type Driver

type Driver string
const (
	DriverSQLite   Driver = "sqlite3"
	DriverPostgres Driver = "postgres"
)

type Migration

type Migration struct {
	Version     int
	Description string
	Up          string
	Down        string
}

Migration represents a database migration

func GetMigrations

func GetMigrations() []Migration

GetMigrations returns all available migrations

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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