Documentation
¶
Index ¶
- Variables
- func ApplySQLiteSessionPragmas(db *sql.DB) error
- func BuildPostgresConnStringFromEnv(databaseName string) (string, error)
- func ConnectDB() (*sql.DB, error)
- func CurrentSchemaVersion(dbconn *sql.DB) (int64, error)
- func CurrentSchemaVersionContext(ctx context.Context, dbconn *sql.DB) (int64, error)
- func DefaultOperationTimeout() time.Duration
- func DefaultStatementTimeout() time.Duration
- func EnsurePostgresSchema(dbconn *sql.DB) error
- func EnsureSchema(dbconn *sql.DB) error
- func NewOperationContext(parent context.Context) (context.Context, context.CancelFunc)
- func QueryCurrentSchemaVersion() (int64, error)
- func QueryWithOptionalForUpdate(dbconn *sql.DB, query string) string
- func QueryWithOptionalForUpdateNowait(dbconn *sql.DB, query string) string
- func QueryWithOptionalForUpdateSkipLocked(dbconn *sql.DB, query string) string
- func RequireExactlyOneRow(result sql.Result, operation string) error
- func RequireRowsAffected(result sql.Result, operation string, expected int64) error
- func RunMigrations(dbconn *sql.DB) error
- func SupportsSelectForUpdate(dbconn *sql.DB) bool
- func SupportsSelectForUpdateNowait(dbconn *sql.DB) bool
- func SupportsSelectForUpdateSkipLocked(dbconn *sql.DB) bool
- type Backend
- type DBTX
Constants ¶
This section is empty.
Variables ¶
var ErrMutationCardinality = errors.New("SQL mutation cardinality mismatch")
ErrMutationCardinality identifies a required SQL mutation that did not affect the expected number of direct target rows.
Functions ¶
func ApplySQLiteSessionPragmas ¶ added in v0.10.0
func BuildPostgresConnStringFromEnv ¶ added in v1.10.2
func CurrentSchemaVersion ¶ added in v1.6.0
CurrentSchemaVersion returns the highest applied schema version in schema_version.
func CurrentSchemaVersionContext ¶ added in v1.13.14
CurrentSchemaVersionContext returns the highest applied schema version using the caller-owned context.
func DefaultOperationTimeout ¶ added in v0.10.0
func DefaultStatementTimeout ¶ added in v0.10.0
func EnsurePostgresSchema ¶ added in v0.10.0
EnsurePostgresSchema validates the runtime PostgreSQL schema. If COLDKEEP_DB_AUTO_BOOTSTRAP is enabled and schema_version is missing, it bootstraps by applying the embedded db/schema_postgres.sql.
func EnsureSchema ¶ added in v1.8.0
EnsureSchema applies/validates schema using the active backend. SQLite: applies embedded schema migrations. Postgres: validates or bootstraps schema and enforces minimum version.
func NewOperationContext ¶ added in v0.10.0
func QueryCurrentSchemaVersion ¶ added in v1.6.0
QueryCurrentSchemaVersion connects using runtime DB settings and returns MAX(schema_version.version).
func QueryWithOptionalForUpdate ¶ added in v0.10.0
QueryWithOptionalForUpdate appends FOR UPDATE only for backends that support it.
func QueryWithOptionalForUpdateNowait ¶ added in v0.10.0
QueryWithOptionalForUpdateNowait appends FOR UPDATE NOWAIT when supported.
func QueryWithOptionalForUpdateSkipLocked ¶ added in v0.10.0
QueryWithOptionalForUpdateSkipLocked appends FOR UPDATE SKIP LOCKED when supported.
func RequireExactlyOneRow ¶ added in v1.13.11
RequireExactlyOneRow verifies that a mutation affected one direct target row.
func RequireRowsAffected ¶ added in v1.13.11
RequireRowsAffected verifies the direct row count reported by a mutation. Operation must be a bounded logical label; callers must not include SQL text, connection details, paths, hashes, or bound values.
func RunMigrations ¶ added in v0.8.0
RunMigrations applies the embedded SQLite schema to a DB connection. It is intended for simulated/local SQLite contexts only.
func SupportsSelectForUpdate ¶ added in v0.10.0
SupportsSelectForUpdate reports whether SELECT ... FOR UPDATE is supported.
func SupportsSelectForUpdateNowait ¶ added in v0.10.0
SupportsSelectForUpdateNowait reports whether FOR UPDATE NOWAIT is supported.
func SupportsSelectForUpdateSkipLocked ¶ added in v0.10.0
SupportsSelectForUpdateSkipLocked reports whether FOR UPDATE SKIP LOCKED is supported.
Types ¶
type Backend ¶ added in v0.10.0
type Backend string
Backend identifies the SQL backend in use for a given *sql.DB.
func BackendFromDB ¶ added in v0.10.0
BackendFromDB detects the configured backend from the DB driver.