Releases: standards-lab/go-database
Releases · standards-lab/go-database
Release list
v0.7.0
Removed
- Breaking:
admin.Registerandadmin.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-corerequirement is v0.5.0; the integer overrides use itsconfig.SetFromEnv. - Breaking:
database.ErrConnectionFailedissqlate.ErrConnectionFailed, one sentinel for
a failure to reach the database, whether the pool or a session raised it. - Breaking:
Service.Forcerefuses a version that is not one of the named set's migrations
withadmin.ErrValidation, before any I/O. It returned the migrator's
migrate.ErrVersionNotFoundbefore. - Breaking:
Service.Readyreports the schema alone: every set's history clean and current.
A seeder whose statements do not prepare failsVerifyandStartbut no longer clears it,
andStartsets it once, when every step has passed. Service.Resetwith an empty state resets to the configuredOptions.Seedset, as
Service.Seeddoes. It refused withadmin.ErrSeedDisabledbefore.Service.Statesreturns a copy of the seeder's list.- The
admin.Seedercontract states thatSeedstays 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.ErrConflictwraps 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
migratesentinel kept in the chain.database.Config.Finalizedreports whetherFinalizehas filled every fieldNewreads; the
providers check it.database.DB.ConnTimeoutreturns the configuredconn_timeout.- Once
Starthas succeeded, a not-readyService.Readyverifies the schema itself, one probe
at a time, at most once per five seconds, and bounded by the pool'sconn_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
GETof the schema's status or a lost connection, clearedService.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.SeedfailedStartonly after it had applied pending migrations; it
now fails beforeStartreads the schema.
postgres/v0.4.0
Changed
- Breaking: requires
github.com/standards-lab/go-databasev0.7.0, whose
ErrConnectionFailedissqlate's sentinel. Newchecks the config withdatabase.Config.Finalized, so a config missing any field the
base reads panics as the base'sNewdoes; it checked onlyConnTimeoutbefore.
Fixed
- A
Hostthat is a Unix-socket directory (starting with/) failed to parse, becauseNew
joined it into the URL's authority.Newnow passes it, with the port, in the URL's query.
v0.6.2
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
Changed
- The
sqlaterequirement is v0.4.1, whoseForcewrites a set's whole history prefix through
the version. On v0.4.0,Service.Forceforcing a set with more than one migration from 0 back
to its head left a history every laterStatus,Verify,Up,Down, andResetrefused
withmigrate.ErrUnknownVersion. The service's own code is unchanged.
v0.6.0
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
sqlaterequirement is v0.4.0, whose migrator runs one or moremigrate.Sets, each over
its own history table. - Breaking:
admin.Statusis{Ready, Sets}: oneadmin.SetStatusper 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.Statusreturns 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, andService.Forcetake the name of the set
they act on.Force(ctx, set, version)is the repair for a dirty set. Service.Resetreverts 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.Startlogs 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
Changed
- Breaking:
admin.Seederis a mechanism over named sets:States() []stringlists the
names it declares andSeed(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.Seedis a state name, the set that applies at every startup once
the schema is current; empty applies none. A name without aSeederpanics; a name the seeder
does not declare fails startup withErrUnknownState. - Breaking:
admin.Service.Seedtakes a state name; empty applies the configured set.
ErrSeedDisablednow 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 aTransitionwith the state, the refreshedStatus, and the rows seeded. It
is destructive, in the class ofDownandForce.admin.Service.Stateslists the seeder's declared names;admin.ErrUnknownStateclassifies
an undeclared name, refused before any I/O.
v0.4.0
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, andseedpackages are removed. Authored SQL
files oversqlate/queryreplace the statement vocabulary and the runners;sqlate/migrate
and a consumer's own seed statements replaceseed. - Breaking: the
Session,Tx, andDialecttypes,ExecTx, and theProviderconstant
are removed, with theDB.Dialect,DB.Begin,DB.QueryContext,DB.QueryRowContext, and
DB.ExecContextmethods. Thesqlatepackage owns the session and the dialect. - Breaking: the four constraint-class sentinels,
ConstraintError, andErrVersionMismatch
are removed. Thesqlatepackage owns the constraint classes andsqlate/querythe version
mismatch; thesqlate/postgresdialect classifies driver errors inside the session. - Breaking:
NewisNew(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
buildtask and the CI build step run each module withGOWORK=off, so a pin that no
longer builds fails rather than being masked by the committedgo.work.
Added
admin: the database admin service.Newtakes the pool's lifecycle object, thesqlate
session, a prebuiltmigrate.Migrator, and the pattern catalog;Optionscarries a
Seeder, aRegistryof compiled statements, a logger, and the seed switch.Register
declares the service at lifecycleStage1;Startverifies the history, applies a pending
set, verifies the seeder, and seeds when enabled.Verify,Status,Up,Down,Steps,
Force, andSeedare triggers over the library's functions;CatalogandStatements
read build-time state;Diagnosepings, reads the server's version through the dialect's
optionalVersionercapability, and reports the pool's counters.- The base module requires
github.com/standards-lab/sqlatev0.1.0, a standard-library-only
module.
postgres/v0.3.0
Changed
- Breaking: the provider supplies no dialect. The
dialecttype, itsMapError
classification into the base module's constraint classes, and itsast.ReturningRenderer
capability are removed; thesqlate/postgrespackage owns the PostgreSQL dialect, and a
composition root wraps the pool it constructs withsqlate.Wrap.Newkeeps its signature
and calls the base module'sNew(conn, cfg). - Breaking: the
Providerconstant is removed with the base module'sProvidertype. - Requires
github.com/standards-lab/go-databasev0.4.0.
v0.3.0
Changed
- Breaking: the
querypackage is reorganized into the library's layer ontology. The
statement layer is nowast— the standard-SQL AST and its renderer — and the contract
layer moves to the newoperationpackage:Projection(withFieldand the builders),
Directives, and the typed field-contract errors. Statements render with
Render(d) (ast.SQL, error)in place ofSQL(d) (string, []any, error);ast.SQLis the
rendered unit (Text,Args). The list operation isProjection.List, returning the
Listenvelope (Count,Page) in place ofStatements. - Breaking: the
Queryinterface narrows to the query expressions —Selectand
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 statementsInsert,Update(withAssignment), andDelete: plain
table names, operand-lifting values, the same predicate trees for WHERE, rendering only at
the outermost position. TheReturningclause is the first declared-native feature:
rendered only through theReturningRenderercapability, failing with the typed
UnsupportedFeatureErroron a dialect without it — the capability pattern's second
direction besidePagingRenderer's standard-emission override.WritergainsColumn;
ExpressiongainsEmpty.operation— the query side's single-row readProjection.One, resolving the field and
its typed unknown-field error at the library; the promoted structural buildersColumns
andFields; the promotedRecursivePathcomputed-field pattern; and the command side:
Insertion(the identity-returning insert),GuardedUpdateandGuardedDeleteon the
optimistic-concurrency contract, withGuardnaming the consumer's version column and
expected version, and theGuardedcommand-and-check envelope in pure standard SQL.exec— the execution layer, the only layer touching database/sql at runtime:Scan, the
query runnersList,One, andQueryover the newSessionseam, and the command
runnersInsert(returningIdentity),Update(returning the deterministic new
version), andDelete, mapping guard outcomes tosql.ErrNoRowsand
ErrVersionMismatchand routing every driver error through the dialect'sMapError.database— theSessioninterface implemented byDBand the newTx;Begin,
ExecTxas the unit-of-work helper, andTx.Commitmapping 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, andConstraintError
carrying the constraint name while unwrapping to both the class and the driver error.
postgres/v0.2.0
Added
MapErrorclassifies SQLSTATE class-23 constraint violations into the base package's
sentinels — unique (23505), foreign-key (23503), check (23514), not-null (23502) — through
aConstraintErrorcarrying the constraint name pgx exposes structurally; every other
error,sql.ErrNoRowsincluded, passes through unchanged.- The dialect implements
ast.ReturningRenderer, the declared-native returning capability,
emitting the postgresRETURNINGform 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.