Documentation
¶
Index ¶
- Constants
- Variables
- func Migrate(ctx context.Context, db *sql.DB, d sqlcommon.Dialect) ([]int, error)
- func MigrationSet(d sqlcommon.Dialect) (sqlcommon.MigrationSet, error)
- func Rollback(ctx context.Context, db *sql.DB, d sqlcommon.Dialect, target int) ([]int, error)
- func Version(ctx context.Context, db *sql.DB, d sqlcommon.Dialect) (int, error)
- type Options
- type Store
- func (s *Store) Append(ctx context.Context, rec audit.Record) (audit.Record, error)
- func (s *Store) DB() *sql.DB
- func (s *Store) Get(ctx context.Context, id int64) (audit.Record, error)
- func (s *Store) List(ctx context.Context, q audit.Query, p audit.Page) (audit.Result[audit.Record], error)
- func (s *Store) Prune(ctx context.Context, before time.Time) (int, error)
Constants ¶
View Source
const MigrationsTable = "audit_schema_migrations"
MigrationsTable records the applied versions of the audit schema, separate from the storage, DDM, DEP, ACME, and admin tables so the version sequences never mix.
Variables ¶
View Source
var ErrUnsupportedDialect = errors.New("sqlstore: unsupported dialect")
ErrUnsupportedDialect is returned for a dialect without embedded migrations.
Functions ¶
func MigrationSet ¶
func MigrationSet(d sqlcommon.Dialect) (sqlcommon.MigrationSet, error)
MigrationSet returns the audit migrations for the dialect.
Types ¶
type Options ¶
type Options struct {
// SkipMigrate leaves the schema alone; the caller has run Migrate.
SkipMigrate bool
}
Options tune Open.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store implements audit.Store over a *sql.DB it does not own: closing the pool is the caller's job.
func Open ¶
Open wraps an opened pool for the dialect and, unless o.SkipMigrate, applies pending migrations.
func (*Store) Append ¶
Append implements audit.Store.
The id is read back rather than assumed, because the three dialects assign it differently and the value is the pagination cursor.
Click to show internal directories.
Click to hide internal directories.