sqldb/sqlite: enable incremental auto_vacuum on DB creation

This commit is contained in:
Olaoluwa Osuntokun
2025-04-03 16:17:59 -07:00
parent a0d6a5591f
commit 9f5bf49ac7

View File

@ -40,6 +40,12 @@ var (
_ DB = (*SqliteStore)(nil)
)
// pragmaOption holds a key-value pair for a SQLite pragma setting.
type pragmaOption struct {
name string
value string
}
// SqliteStore is a database store implementation that uses a sqlite backend.
type SqliteStore struct {
cfg *SqliteConfig
@ -53,10 +59,7 @@ func NewSqliteStore(cfg *SqliteConfig, dbPath string) (*SqliteStore, error) {
// The set of pragma options are accepted using query options. For now
// we only want to ensure that foreign key constraints are properly
// enforced.
pragmaOptions := []struct {
name string
value string
}{
pragmaOptions := []pragmaOption{
{
name: "foreign_keys",
value: "on",
@ -84,6 +87,10 @@ func NewSqliteStore(cfg *SqliteConfig, dbPath string) (*SqliteStore, error) {
name: "fullfsync",
value: "true",
},
{
name: "auto_vacuum",
value: "incremental",
},
}
sqliteOptions := make(url.Values)
for _, option := range pragmaOptions {