chore: auto-commit (95 archivos)
- cmd/fn/doctor.go - cmd/fn/main.go - cpp/apps/primitives_gallery/playground/tables/CMakeLists.txt - cpp/apps/primitives_gallery/playground/tables/data_table.cpp - cpp/apps/primitives_gallery/playground/tables/data_table_logic.cpp - cpp/apps/primitives_gallery/playground/tables/data_table_logic.h - cpp/apps/primitives_gallery/playground/tables/self_test.cpp - cpp/apps/primitives_gallery/playground/tables/tql.cpp - cpp/apps/primitives_gallery/playground/tables/viz.cpp - cpp/apps/primitives_gallery/playground/tables/viz.h - ... Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package infra
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"embed"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
//go:embed vault_index_migrations/*.sql
|
||||
var vaultIndexMigrationsFS embed.FS
|
||||
|
||||
// VaultIndexOpen opens (or creates) the vault_index.db inside vaultPath.
|
||||
// It applies all embedded migrations idempotently and returns a ready-to-use
|
||||
// *sql.DB. The caller is responsible for closing the connection.
|
||||
//
|
||||
// The database is opened with WAL mode and foreign keys enabled via SQLiteOpen.
|
||||
// Migrations are applied from vault_index_migrations/*.sql in lexicographic order.
|
||||
func VaultIndexOpen(vaultPath string) (*sql.DB, error) {
|
||||
dbPath := filepath.Join(vaultPath, "vault_index.db")
|
||||
db, err := SQLiteOpen(dbPath, "")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("vault_index_open: %w", err)
|
||||
}
|
||||
if err := ApplyMigrations(db, vaultIndexMigrationsFS, "vault_index_migrations/*.sql"); err != nil {
|
||||
db.Close()
|
||||
return nil, fmt.Errorf("vault_index_open: apply migrations: %w", err)
|
||||
}
|
||||
return db, nil
|
||||
}
|
||||
Reference in New Issue
Block a user