Skip to content

Releases: standards-lab/go-database

v0.7.0

Choose a tag to compare

@github-actions github-actions released this 30 Sep 11:18
de86deb

Removed

  • Breaking: admin.Register and admin.Stage. The consumer declares the service on its
    coordinator at the stage its own stage table names:
    lc.Add(lifecycle.Service{Name: "schema", Stage: <stage>, Start: svc.Start, Check: svc}).

Changed

  • The go-core requirement is v0.5.0; the integer overrides use its config.SetFromEnv.
  • Breaking: database.ErrConnectionFailed is sqlate.ErrConnectionFailed, one sentinel for
    a failure to reach the database, whether the pool or a session raised it.
  • Breaking: Service.Force refuses a version that is not one of the named set's migrations
    with admin.ErrValidation, before any I/O. It returned the migrator's
    migrate.ErrVersionNotFound before.
  • Breaking: Service.Ready reports the schema alone: every set's history clean and current.
    A seeder whose statements do not prepare fails Verify and Start but no longer clears it,
    and Start sets it once, when every step has passed.
  • Service.Reset with an empty state resets to the configured Options.Seed set, as
    Service.Seed does. It refused with admin.ErrSeedDisabled before.
  • Service.States returns a copy of the seeder's list.
  • The admin.Seeder contract states that Seed stays idempotent when replicas seed at once.
  • Each package comment lists the package's API, and each contract is stated once, on its symbol.

Added

  • admin.ErrConflict wraps every refusal the schema's state causes (dirty, pending, a history
    its set does not carry, a migration with no down, a set order the migrator forbids), with the
    migrate sentinel kept in the chain.
  • database.Config.Finalized reports whether Finalize has filled every field New reads; the
    providers check it.
  • database.DB.ConnTimeout returns the configured conn_timeout.
  • Once Start has succeeded, a not-ready Service.Ready verifies the schema itself, one probe
    at a time, at most once per five seconds, and bounded by the pool's conn_timeout, so a
    replica whose schema is corrected out of band returns to rotation. A probe's clean finding
    yields to any operation that determined the schema while it read.

Fixed

  • An admin operation that failed without determining the schema's state, such as a cancelled
    GET of the schema's status or a lost connection, cleared Service.Ready, taking the replica
    out of rotation until another operation found the schema current. Ready now changes only on a
    determined state.
  • A misspelled Options.Seed failed Start only after it had applied pending migrations; it
    now fails before Start reads the schema.

postgres/v0.4.0

Choose a tag to compare

@github-actions github-actions released this 30 Sep 11:19

Changed

  • Breaking: requires github.com/standards-lab/go-database v0.7.0, whose
    ErrConnectionFailed is sqlate's sentinel.
  • New checks the config with database.Config.Finalized, so a config missing any field the
    base reads panics as the base's New does; it checked only ConnTimeout before.

Fixed

  • A Host that is a Unix-socket directory (starting with /) failed to parse, because New
    joined it into the URL's authority. New now passes it, with the port, in the URL's query.

v0.6.2

Choose a tag to compare

@github-actions github-actions released this 29 Sep 17:06
1e4800e

Changed

  • admin.Stage's documentation states what it asks of a consumer, the pool registered at stage 0,
    and no longer names a stage for the consumer's domains to verify their statements at; the
    consumer chooses it.

v0.6.1

Choose a tag to compare

@github-actions github-actions released this 24 Sep 22:58

Changed

  • The sqlate requirement is v0.4.1, whose Force writes a set's whole history prefix through
    the version. On v0.4.0, Service.Force forcing a set with more than one migration from 0 back
    to its head left a history every later Status, Verify, Up, Down, and Reset refused
    with migrate.ErrUnknownVersion. The service's own code is unchanged.

v0.6.0

Choose a tag to compare

@github-actions github-actions released this 24 Sep 17:54
908348c

The admin service administers a migrator running several migration sets, such as a library's
shipped set beneath the consumer's own. The first such set is blobfs's.

Changed

  • The sqlate requirement is v0.4.0, whose migrator runs one or more migrate.Sets, each over
    its own history table.
  • Breaking: admin.Status is {Ready, Sets}: one admin.SetStatus per set, in declared
    order, with its name, history table, head, latest version, dirty mark, pending versions, and
    migrations. Ready is true when every set is clean and complete. A dirty set's pending
    versions are the ones above its dirty head; the single-set status reported none.
  • Service.Status returns the migrator's error, naming the set, when a history carries a row
    its set does not, and clears Ready. It reported that history as not ready before.
  • Breaking: Service.Down, Service.Steps, and Service.Force take the name of the set
    they act on. Force(ctx, set, version) is the repair for a dirty set.
  • Service.Reset reverts every set, the last declared first, dropping each history table, then
    applies every set and seeds the named state. It reverted only the one set before.
  • Service.Start logs the pending migrations set by set before it applies them, and each set's
    head once current.

Added

  • admin.ErrUnknownSet, returned before any I/O when a verb names no set or a set the migrator
    does not run.
  • admin.SetStatus.

v0.5.0

Choose a tag to compare

@github-actions github-actions released this 07 Sep 17:47

Changed

  • Breaking: admin.Seeder is a mechanism over named sets: States() []string lists the
    names it declares and Seed(ctx, state) applies one. A set is the data a deployment or a
    scenario starts from, declared by the consumer, applied idempotently.
  • Breaking: admin.Options.Seed is a state name, the set that applies at every startup once
    the schema is current; empty applies none. A name without a Seeder panics; a name the seeder
    does not declare fails startup with ErrUnknownState.
  • Breaking: admin.Service.Seed takes a state name; empty applies the configured set.
    ErrSeedDisabled now means no seeder, or no set named or configured.

Added

  • admin.Service.Reset: the transition to a named state. It reverts every applied migration,
    applies the whole set, and seeds the state's set, each through the function the verbs run,
    and returns a Transition with the state, the refreshed Status, and the rows seeded. It
    is destructive, in the class of Down and Force.
  • admin.Service.States lists the seeder's declared names; admin.ErrUnknownState classifies
    an undeclared name, refused before any I/O.

v0.4.0

Choose a tag to compare

@github-actions github-actions released this 04 Sep 21:36
928908e

The module is reduced to the SQL infrastructure service over the sqlate library
(github.com/standards-lab/sqlate), which owns everything from the .sql file to the scanned
row. A composition root wraps the pool this module constructs with sqlate.Wrap and the engine's
dialect from sqlate/postgres, compiles its statements through sqlate/query, and migrates
through sqlate/migrate.

Changed

  • Breaking: the ast, operation, exec, and seed packages are removed. Authored SQL
    files over sqlate/query replace the statement vocabulary and the runners; sqlate/migrate
    and a consumer's own seed statements replace seed.
  • Breaking: the Session, Tx, and Dialect types, ExecTx, and the Provider constant
    are removed, with the DB.Dialect, DB.Begin, DB.QueryContext, DB.QueryRowContext, and
    DB.ExecContext methods. The sqlate package owns the session and the dialect.
  • Breaking: the four constraint-class sentinels, ConstraintError, and ErrVersionMismatch
    are removed. The sqlate package owns the constraint classes and sqlate/query the version
    mismatch; the sqlate/postgres dialect classifies driver errors inside the session.
  • Breaking: New is New(conn *sql.DB, cfg Config) *DB. It panics on an unfinalized
    config or a nil pool, the wiring rule the package comment now states.
  • The build task and the CI build step run each module with GOWORK=off, so a pin that no
    longer builds fails rather than being masked by the committed go.work.

Added

  • admin: the database admin service. New takes the pool's lifecycle object, the sqlate
    session, a prebuilt migrate.Migrator, and the pattern catalog; Options carries a
    Seeder, a Registry of compiled statements, a logger, and the seed switch. Register
    declares the service at lifecycle Stage 1; Start verifies the history, applies a pending
    set, verifies the seeder, and seeds when enabled. Verify, Status, Up, Down, Steps,
    Force, and Seed are triggers over the library's functions; Catalog and Statements
    read build-time state; Diagnose pings, reads the server's version through the dialect's
    optional Versioner capability, and reports the pool's counters.
  • The base module requires github.com/standards-lab/sqlate v0.1.0, a standard-library-only
    module.

postgres/v0.3.0

Choose a tag to compare

@github-actions github-actions released this 04 Sep 21:38

Changed

  • Breaking: the provider supplies no dialect. The dialect type, its MapError
    classification into the base module's constraint classes, and its ast.ReturningRenderer
    capability are removed; the sqlate/postgres package owns the PostgreSQL dialect, and a
    composition root wraps the pool it constructs with sqlate.Wrap. New keeps its signature
    and calls the base module's New(conn, cfg).
  • Breaking: the Provider constant is removed with the base module's Provider type.
  • Requires github.com/standards-lab/go-database v0.4.0.

v0.3.0

Choose a tag to compare

@github-actions github-actions released this 28 Aug 14:20
860cdad

Changed

  • Breaking: the query package is reorganized into the library's layer ontology. The
    statement layer is now ast — the standard-SQL AST and its renderer — and the contract
    layer moves to the new operation package: Projection (with Field and the builders),
    Directives, and the typed field-contract errors. Statements render with
    Render(d) (ast.SQL, error) in place of SQL(d) (string, []any, error); ast.SQL is the
    rendered unit (Text, Args). The list operation is Projection.List, returning the
    List envelope (Count, Page) in place of Statements.
  • Breaking: the Query interface narrows to the query expressions — Select and
    Compound, the statements valid inside a CTE, a derived table, a subquery, and
    INSERT ... SELECT — enforced at compile time; the write statements never implement it.
  • Rendering validates before it emits, at every scope: each statement, clause, and loop
    iteration checks the invariants decidable at its entry before its first write, so the
    outermost defect wins under the first-failure rule.

Added

  • ast — the write statements Insert, Update (with Assignment), and Delete: plain
    table names, operand-lifting values, the same predicate trees for WHERE, rendering only at
    the outermost position. The Returning clause is the first declared-native feature:
    rendered only through the ReturningRenderer capability, failing with the typed
    UnsupportedFeatureError on a dialect without it — the capability pattern's second
    direction beside PagingRenderer's standard-emission override. Writer gains Column;
    Expression gains Empty.
  • operation — the query side's single-row read Projection.One, resolving the field and
    its typed unknown-field error at the library; the promoted structural builders Columns
    and Fields; the promoted RecursivePath computed-field pattern; and the command side:
    Insertion (the identity-returning insert), GuardedUpdate and GuardedDelete on the
    optimistic-concurrency contract, with Guard naming the consumer's version column and
    expected version, and the Guarded command-and-check envelope in pure standard SQL.
  • exec — the execution layer, the only layer touching database/sql at runtime: Scan, the
    query runners List, One, and Query over the new Session seam, and the command
    runners Insert (returning Identity), Update (returning the deterministic new
    version), and Delete, mapping guard outcomes to sql.ErrNoRows and
    ErrVersionMismatch and routing every driver error through the dialect's MapError.
  • database — the Session interface implemented by DB and the new Tx; Begin,
    ExecTx as the unit-of-work helper, and Tx.Commit mapping commit errors through the
    dialect, so violations deferred to COMMIT are classified. The error taxonomy grows the
    four constraint-class sentinels (ErrUniqueViolation, ErrForeignKeyViolation,
    ErrCheckViolation, ErrNotNullViolation), ErrVersionMismatch, and ConstraintError
    carrying the constraint name while unwrapping to both the class and the driver error.

postgres/v0.2.0

Choose a tag to compare

@github-actions github-actions released this 28 Aug 14:23

Added

  • MapError classifies SQLSTATE class-23 constraint violations into the base package's
    sentinels — unique (23505), foreign-key (23503), check (23514), not-null (23502) — through
    a ConstraintError carrying the constraint name pgx exposes structurally; every other
    error, sql.ErrNoRows included, passes through unchanged.
  • The dialect implements ast.ReturningRenderer, the declared-native returning capability,
    emitting the postgres RETURNING form for the write statements.

Changed

  • The go-database pin moves to v0.3.0, the release carrying the ast/operation/exec
    layer ontology this provider's capabilities plug into.