database

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package database provides database initialization, migration, and management utilities for the 4y-ui panel using GORM with SQLite.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Checkpoint

func Checkpoint() error

Checkpoint performs a WAL checkpoint on the SQLite database to ensure data consistency.

func CloseDB

func CloseDB() error

CloseDB closes the database connection if it exists.

func GetDB

func GetDB() *gorm.DB

GetDB returns the global GORM database instance.

func InitDB

func InitDB(dbPath string) error

InitDB sets up the database connection, migrates models, and runs seeders.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound checks if the given error is a GORM record not found error.

func IsSQLiteDB

func IsSQLiteDB(file io.ReaderAt) (bool, error)

IsSQLiteDB checks if the given file is a valid SQLite database by reading its signature.

func ValidateSQLiteDB

func ValidateSQLiteDB(dbPath string) error

ValidateSQLiteDB opens the provided sqlite DB path with a throw-away connection and runs a PRAGMA integrity_check to ensure the file is structurally sound. It does not mutate global state or run migrations.

Types

This section is empty.

Directories

Path Synopsis
Package model defines the database models and data structures used by the 4y-ui panel.
Package model defines the database models and data structures used by the 4y-ui panel.

Jump to

Keyboard shortcuts

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