database

package
v0.7.16 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Checkpoint

func Checkpoint(db *gorm.DB) error

Checkpoint 把 WAL 中的改动全部并回主库文件并截断 WAL。 备份、导入、迁移之后必须调用:否则单独复制 .db 文件会丢失尚在 WAL 中的数据。

func CheckpointPassive added in v0.6.8

func CheckpointPassive(db *gorm.DB) error

CheckpointPassive 不阻塞任何读写的检查点:定时循环用它,把 WAL 能并回去的并回去就行。 TRUNCATE 要等所有读写让路、还要把主库 fsync 一遍,盘慢时面板会跟着卡几秒;那只留给备份和停机。

func Close

func Close(db *gorm.DB) error

Close 检查点后关闭底层连接,使数据库文件自洽、可安全复制。

func Open

func Open(dbPath string) (*gorm.DB, error)

Open 打开(必要时创建)m-ui 数据库并迁移表结构。 使用纯 Go 的 SQLite 驱动(modernc),无 CGO:交叉编译零依赖,单二进制。

func OpenReadOnly

func OpenReadOnly(dbPath string) (*gorm.DB, error)

OpenReadOnly 只读打开一个既有 SQLite 文件(用于导入旧库,绝不写源文件)。

Types

type DBHandle

type DBHandle struct{ DB *gorm.DB }

DBHandle 是测试里携带 *gorm.DB 的小包装。

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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