Documentation
¶
Index ¶
- func ColumnExists(exec Executor, table, column string) (bool, error)
- func IndexExists(exec Executor, index string) (bool, error)
- func ResolveDBPathOverride(pathOverride string, defaultPath func() (string, error)) (string, error)
- func SchemaSignature(ctx context.Context, db *sql.DB) ([]string, error)
- func TableExists(exec Executor, table string) (bool, error)
- func TriggerExists(exec Executor, trigger string) (bool, error)
- func UserTableCount(exec Executor) (int, error)
- func ValidateMigrations(migrations []Migration, firstVersion, targetVersion int, contiguous bool) error
- func WithImmediateMigrationTx(ctx context.Context, db *sql.DB, fn func(Executor) error) (err error)
- type Executor
- type Migration
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ColumnExists ¶ added in v0.0.406
ColumnExists reports whether table contains column.
func IndexExists ¶ added in v0.0.406
IndexExists reports whether a named index exists.
func ResolveDBPathOverride ¶
ResolveDBPathOverride expands and absolutizes an optional SQLite database path. An empty override delegates to defaultPath; :memory: is returned unchanged.
func SchemaSignature ¶ added in v0.0.406
SchemaSignature captures a normalized structural signature for tests and diagnostics. It includes sqlite_master SQL, complete table_info metadata, and foreign-key metadata while excluding SQLite's auto-generated object names. It is intentionally not used by normal migration startup paths.
func TableExists ¶ added in v0.0.406
TableExists reports whether a table or virtual table exists.
func TriggerExists ¶ added in v0.0.406
TriggerExists reports whether a named trigger exists.
func UserTableCount ¶ added in v0.0.406
UserTableCount returns the number of non-SQLite-owned tables. It is useful only while classifying an unversioned database on a locked slow path.
func ValidateMigrations ¶ added in v0.0.406
func ValidateMigrations(migrations []Migration, firstVersion, targetVersion int, contiguous bool) error
ValidateMigrations validates a migration list. When contiguous is true, the first version must equal firstVersion and every following version must be the next integer. A non-empty list must end at targetVersion.
func WithImmediateMigrationTx ¶
WithImmediateMigrationTx runs fn on a dedicated connection in a SQLite BEGIN IMMEDIATE transaction. SQLite's configured busy_timeout governs lock acquisition; this function does not add an unbounded retry loop.
Cleanup uses a short context independent of ctx, so cancellation cannot skip rollback. If rollback cannot be confirmed, database/sql's Raw hook returns driver.ErrBadConn, which tells the pool to discard rather than reuse the connection.
Types ¶
type Executor ¶
type Executor interface {
Exec(query string, args ...any) (sql.Result, error)
Query(query string, args ...any) (*sql.Rows, error)
QueryRow(query string, args ...any) *sql.Row
}
Executor is the context-bound query surface exposed to a migration transaction. Implementations must keep every operation on the same SQLite connection.