store

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package store provides database initialization and migration utilities.

Package store: FTS5 setup used by Migrate (GORM does not support FTS5 virtual tables).

Package store provides test utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close(db *gorm.DB) error

Close closes the database connection

func InitDB

func InitDB(cfg Config) (*gorm.DB, error)

InitDB initializes the database connection with GORM. If cfg.AutoMigrate is true, it automatically runs Migrate after connection.

func Migrate

func Migrate(db *gorm.DB) error

Migrate runs GORM AutoMigrate for all models, then creates the FTS5 virtual table and triggers (not expressible in GORM). This is the only supported schema path.

func SetupTestDB

func SetupTestDB(t *testing.T) *gorm.DB

SetupTestDB creates a test database (in-memory or temp file).

Types

type Config

type Config struct {
	Path        string
	WALEnabled  bool
	LogLevel    logger.LogLevel
	AutoMigrate bool // Automatically run Migrate on InitDB if true
}

Config holds database configuration

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns default database configuration. AutoMigrate defaults to true for ease of use.

Jump to

Keyboard shortcuts

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