Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ SQL templating for Go: authored `.sql` files made dynamic and composable, with a
dialect and a conventions linter.

`github.com/standards-lab/sqlate` is the base module, and it imports only the standard library.
The PostgreSQL dialect is the `postgres` sub-module and the linter is the `sqlint` sub-module,
each released on its own tags.
The `postgres` sub-module is the PostgreSQL dialect, the `postgres/pgvector` sub-module names
the pgvector extension, and the `sqlint` sub-module is the linter. Each sub-module is released on
its own tags.

## The problem

Expand Down Expand Up @@ -114,30 +115,42 @@ Three conventions the library keeps are stricter than a reader might expect:
advisory lock, the extension statements, and the engine's native forms. Its `pgtest` package
gives an integration test its own throwaway database, migrated or empty, dropped when the test
ends.
- `postgres/pgvector` (sub-module) names the pgvector extension: its catalog name, `vector`, and
the metric table of the `vector` type, each metric's distance operator and index operator
class. Its `sqlint.toml` exports pgvector's native forms. It imports only the standard
library; its tests take `postgres` for `pgtest`.
- `sqlint` (sub-module) is the conventions linter as a package, with the command at
`sqlint/cmd/sqlint`.

## Development

The repository is a Go workspace of three modules. Tasks run through
The repository is a Go workspace of four modules. Tasks run through
[mise](https://mise.jdx.dev):

```sh
mise run check # build, vet, format, fix, tidy, unit tier, lint, sqlint, lint-context, lint-references; writes nothing
mise run currency # report requirements, Go, tools, actions, and images behind their latest
mise run currency # report requirements, Go, tools, actions, images, and Dockerfile source ARGs behind their latest
mise run upgrade # upgrade every module's go directive and requirements, and the tools, to their latest
mise run db:up # build and start the compose PostgreSQL and wait until it is healthy
mise run db:down # stop PostgreSQL, keeping its data
mise run db:reset # stop PostgreSQL and drop its data
mise run integration # run the integration tier against the running PostgreSQL
mise run integration # run the integration tier of postgres and postgres/pgvector against the running PostgreSQL
mise run acceptance # run db:up and integration, then db:reset whatever the result
```

`compose.yml` runs PostgreSQL on port 5433, beside a service's own on 5432; `POSTGRES_PORT`
moves it. The service builds from `compose/postgres/Dockerfile`, whose `FROM` line is its one
image pin and which carries its configuration and health check; `mise run currency` reports a
pin behind its latest. `mise.toml` sets `SQLATE_DSN`, whose port follows the same variable. The
integration tier is not part of CI.
image pin and which carries its configuration and health check. The Dockerfile builds pgvector
from source at `ARG PGVECTOR_VERSION`, the extension's one version pin
([the image](docs/features.md#an-image-with-pgvector)). `mise run currency` reports either pin
when it trails its latest: it compares the `FROM` tag with the image's tags, and the `ARG` with
the highest semver tag of the GitHub repository that the `ADD` line fetches. `mise.toml` sets
`SQLATE_DSN`, whose port follows `POSTGRES_PORT`.

The integration tier covers two modules, `postgres` and `postgres/pgvector`, each behind the
`integration` build tag. `mise run integration` runs both against the running PostgreSQL, and
`mise run acceptance` starts the compose PostgreSQL, runs both, and drops its data. The tier runs
on a developer's machine, not in CI.

The compose PostgreSQL reports healthy once it accepts TCP connections to the app database. The
probe goes over TCP, not the socket, because the first start's initialization runs a temporary
Expand Down
4 changes: 2 additions & 2 deletions STANDARDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
The judgement calls the standards-reviewer applies to sqlate, beyond what `mise run check` enforces.

- A change that alters documented behavior updates the guide, `README.md` and `docs/`, in the same change.
- `architecture/standards/go-elemental/principles/dependencies.md`: the three modules' `go.mod` files.
- `architecture/standards/go-elemental/principles/dependencies.md`: the four modules' `go.mod` files.
- `architecture/standards/go-elemental/principles/tests-and-docs.md`: the doc.go inventory of every package, and the unit tier over `sqltest`.
- `architecture/standards/go-elemental/principles/topology-and-naming.md`: the base module and the `postgres` and `sqlint` sub-modules, and their tags.
- `architecture/standards/go-elemental/principles/topology-and-naming.md`: the base module and the `postgres`, `postgres/pgvector`, and `sqlint` sub-modules, and their tags.
- `architecture/standards/go-elemental/principles/release-and-ci.md`: the check, currency, and a changelog per module.
- `architecture/standards/go-elemental/principles/dsl-driven-services.md`: `query`, `header`, and every authored `.sql` file, the library's patterns included.
- `architecture/standards/go-elemental/principles/baseline-standards.md`: `query`'s guards and projections, which take every name and bound from their caller.
Expand Down
12 changes: 12 additions & 0 deletions compose/postgres/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# See README.md
FROM postgres:19.0-alpine

ARG PGVECTOR_VERSION=0.8.7

ADD https://github.com/pgvector/pgvector.git#v${PGVECTOR_VERSION} /usr/src/pgvector

RUN apk add --no-cache --virtual .build-deps build-base \
&& cd /usr/src/pgvector \
&& make with_llvm=no OPTFLAGS="" \
&& make install with_llvm=no \
&& cd / \
&& rm -rf /usr/src/pgvector \
&& apk del .build-deps

ENV POSTGRES_USER=app \
POSTGRES_PASSWORD=app \
POSTGRES_DB=app
Expand Down
4 changes: 4 additions & 0 deletions context/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ express.
([sqltest/doc.go](../sqltest/doc.go)).
- **postgres** (built): the PostgreSQL dialect sub-module, with `pgtest` for integration tests'
throwaway databases ([postgres/doc.go](../postgres/doc.go)).
- **postgres/pgvector** (built): the pgvector extension sub-module. It names the extension's
catalog name, `vector`, and the `vector` type's metric table, exports pgvector's native forms
to sqlint, and proves the extension stage and the per-space index recipe in its own
integration tier ([postgres/pgvector/doc.go](../postgres/pgvector/doc.go)).
- **sqlint** (built): the conventions linter sub-module and its command
([sqlint/doc.go](../sqlint/doc.go)).
- **Dollar-quoted strings in sqlint** (planned): `sqlint` strips PostgreSQL dollar-quoted bodies
Expand Down
Loading