Versions in this module Expand all Collapse all v0 v0.9.2 Sep 14, 2026 v0.9.1 Sep 14, 2026 Changes in this version + const ClearBatchSize + const DefaultMigrationsTable + const RewrapBatchSize + var ErrMigration = errors.New("sqlcommon: migration") + var ErrTransaction = errors.New("sqlcommon: transaction coordination failed") + func AfterCommit(ctx context.Context, fn func(context.Context)) + func AfterCompletion(ctx context.Context, fn func(context.Context, bool)) + func BlobAAD(purpose string, keys ...string) []byte + func CurrentTransaction(ctx context.Context, db *sql.DB) (*sql.Tx, bool) + func Fail(ctx context.Context, err error) error + func InsertIgnoreDuplicateKey(table string, cols, key []string) string + func InsertIgnoreOnConflict(table string, cols, key []string) string + func Migrate(ctx context.Context, db *sql.DB, d Dialect) ([]int, error) + func MigrateSet(ctx context.Context, db *sql.DB, d Dialect, set MigrationSet) ([]int, error) + func MustSub(fsys fs.FS, dir string) fs.FS + func OpenBlob(k *crypt.Keyring, purpose string, b []byte, keys ...string) ([]byte, error) + func PutPushCertTx(ctx context.Context, q interface{ ... }, d Dialect, keys *crypt.Keyring, ...) (storage.PushCert, error) + func RewrapBlobs(ctx context.Context, db *sql.DB, d Dialect, k *crypt.Keyring, ...) (int, error) + func Rollback(ctx context.Context, db *sql.DB, d Dialect, target int) ([]int, error) + func RollbackSet(ctx context.Context, db *sql.DB, d Dialect, set MigrationSet, target int) ([]int, error) + func Savepoint(ctx context.Context, db *sql.DB, fn func(context.Context, *sql.Tx) error) (err error) + func SealBlob(k *crypt.Keyring, purpose string, b []byte, keys ...string) ([]byte, error) + func UpsertOnConflict(table string, cols, key []string) string + func UpsertOnDuplicateKey(table string, cols, _ []string) string + func Version(ctx context.Context, db *sql.DB, d Dialect) (int, error) + func VersionOf(ctx context.Context, db *sql.DB, d Dialect, table string) (int, error) + type BlobColumn struct + Column string + Keys []string + Table string + type Dialect struct + Dollar bool + ForUpdate string + InsertIgnore func(table string, cols, key []string) string + IsUniqueViolation func(error) bool + Migrations fs.FS + Name string + Upsert func(table string, cols, key []string) string + func (d Dialect) Rebind(query string) string + type Migration struct + Down []string + Name string + Up []string + Version int + func LoadMigrations(fsys fs.FS) ([]Migration, error) + type MigrationSet struct + FS fs.FS + Table string + type Option func(*Store) + func WithKeyring(k *crypt.Keyring) Option + type Pool struct + ConnMaxIdleTime time.Duration + ConnMaxLifetime time.Duration + MaxIdleConns int + MaxOpenConns int + func (p Pool) Apply(db *sql.DB) + type Queryer interface + ExecContext func(context.Context, string, ...any) (sql.Result, error) + QueryContext func(context.Context, string, ...any) (*sql.Rows, error) + QueryRowContext func(context.Context, string, ...any) *sql.Row + func Query(ctx context.Context, db *sql.DB) Queryer + type Store struct + func New(db *sql.DB, d Dialect, opts ...Option) *Store + func (s *Store) AssociateCert(ctx context.Context, id mdm.EnrollmentID, hash string, at time.Time) error + func (s *Store) AuthenticateEnrollment(ctx context.Context, id mdm.EnrollmentID, c storage.AuthenticateChange) error + func (s *Store) BootstrapToken(ctx context.Context, id mdm.EnrollmentID) ([]byte, error) + func (s *Store) CertHash(ctx context.Context, id mdm.EnrollmentID) (string, error) + func (s *Store) CertHashHistory(ctx context.Context, hash string) ([]storage.CertAssociation, error) + func (s *Store) CertHistory(ctx context.Context, id mdm.EnrollmentID) ([]storage.CertAssociation, error) + func (s *Store) Clear(ctx context.Context, id mdm.EnrollmentID, f storage.ClearFilter) (int64, error) + func (s *Store) ClearCommand(ctx context.Context, id mdm.EnrollmentID, uuid string) (int64, error) + func (s *Store) ClearUserAuth(ctx context.Context, id mdm.EnrollmentID) error + func (s *Store) Close() error + func (s *Store) Commands(ctx context.Context, id mdm.EnrollmentID, q storage.CommandQuery, ...) (paging.Result[storage.QueuedCommand], error) + func (s *Store) DB() *sql.DB + func (s *Store) Disable(ctx context.Context, id mdm.EnrollmentID, at time.Time) error + func (s *Store) Enqueue(ctx context.Context, ids []mdm.EnrollmentID, cmd *mdm.Command, ...) (storage.EnqueueResult, error) + func (s *Store) EnrollmentByCertHash(ctx context.Context, hash string) (mdm.EnrollmentID, error) + func (s *Store) EnrollmentByID(ctx context.Context, id string) (*storage.Enrollment, error) + func (s *Store) Export(ctx context.Context, p paging.Page) (paging.Result[storage.EnrollmentExport], error) + func (s *Store) Get(ctx context.Context, id mdm.EnrollmentID) (*storage.Enrollment, error) + func (s *Store) Import(ctx context.Context, rec storage.EnrollmentExport) error + func (s *Store) List(ctx context.Context, q storage.EnrollmentQuery, p paging.Page) (paging.Result[storage.Enrollment], error) + func (s *Store) Next(ctx context.Context, id mdm.EnrollmentID, skipNotNow bool, now time.Time) (*mdm.Command, error) + func (s *Store) Ping(ctx context.Context) error + func (s *Store) PushCert(ctx context.Context, topic string) (*storage.PushCert, error) + func (s *Store) PushCertVersion(ctx context.Context, topic string) (int64, error) + func (s *Store) PushCerts(ctx context.Context) ([]storage.PushCert, error) + func (s *Store) PushInfo(ctx context.Context, ids []mdm.EnrollmentID) (map[mdm.EnrollmentID]mdm.Push, error) + func (s *Store) Rewrap(ctx context.Context) (int, error) + func (s *Store) StoreBootstrapToken(ctx context.Context, id mdm.EnrollmentID, token []byte, at time.Time) error + func (s *Store) StorePushCert(ctx context.Context, topic string, certPEM, keyPEM []byte, at time.Time) (storage.PushCert, error) + func (s *Store) StoreResult(ctx context.Context, id mdm.EnrollmentID, resp *mdm.Response, now time.Time) error + func (s *Store) StoreTokenUpdate(ctx context.Context, id mdm.EnrollmentID, push mdm.Push, ...) error + func (s *Store) StoreUserAuthChallenge(ctx context.Context, id mdm.EnrollmentID, challenge string, raw []byte, ...) error + func (s *Store) StoreUserAuthToken(ctx context.Context, id mdm.EnrollmentID, token string, raw []byte, ...) error + func (s *Store) TouchLastSeen(ctx context.Context, id mdm.EnrollmentID, at time.Time) error + func (s *Store) TransitionReplacement(ctx context.Context, id mdm.EnrollmentID, change storage.ReplacementChange) (*storage.Replacement, error) + func (s *Store) UpsertAuthenticate(ctx context.Context, id mdm.EnrollmentID, msg *checkin.Authenticate, ...) error + func (s *Store) UserAuth(ctx context.Context, id mdm.EnrollmentID) (*storage.UserAuthState, error) + type UnitOfWork struct + DB *sql.DB + Dialect Dialect + func (w UnitOfWork) Run(ctx context.Context, fn func(context.Context) error) (err error)