Migrate db and config to mcdsl

- db.Open: delegate to mcdsl/db.Open (WAL, FK, busy timeout, 0600)
- db.Migrate: convert function-based migrations to mcdsl/db.Migration
  SQL strings, delegate to mcdsl/db.Migrate
- db.Snapshot: delegate to mcdsl/db.Snapshot (adds 0600 permissions)
- config: replace local Duration with mcdsl/config.Duration alias,
  replace Load with mcdsl/config.Load[T] + Validator interface
- Remove direct modernc.org/sqlite and go-toml/v2 dependencies
  (now indirect via mcdsl)
- Update TestEnvOverrideInvalidDuration: mcdsl silently ignores
  invalid env duration values (behavioral change from migration)
- All existing tests pass

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-25 16:57:02 -07:00
parent 564e0a9c67
commit 1ad42dbbee
7 changed files with 116 additions and 245 deletions

View File

@@ -1,12 +1,11 @@
package db
import "fmt"
import (
mcdsldb "git.wntrmute.dev/kyle/mcdsl/db"
)
// Snapshot creates a consistent backup of the database using VACUUM INTO.
// The destination file is created with 0600 permissions.
func (s *Store) Snapshot(destPath string) error {
_, err := s.db.Exec("VACUUM INTO ?", destPath)
if err != nil {
return fmt.Errorf("snapshot to %q: %w", destPath, err)
}
return nil
return mcdsldb.Snapshot(s.db, destPath)
}