Documentation
¶
Overview ¶
Package database opens the PostgreSQL pool and applies the embedded migrations. capsa owns its schema: the binary is the only thing that creates or changes tables, at every start.
Index ¶
Constants ¶
const ( StatusOK = "ok" StatusWarning = "warning" StatusFailed = "failed" )
Check statuses.
const MigrationsTable = "schema_migrations"
MigrationsTable is the ledger of applied migrations in the database.
const MinVectorVersion = "0.7.0"
MinVectorVersion is the pgvector the schema needs: halfvec arrived in 0.7.0.
Variables ¶
This section is empty.
Functions ¶
func EnsureDatabase ¶
EnsureDatabase creates the database of the DSN when it does not exist yet. Tests use it for their scratch databases; the server does not: its database is the operator's.
Types ¶
type Check ¶
type Check struct {
Name string `json:"name"`
Status string `json:"status"`
Detail string `json:"detail"`
// Fix is what to do about it, when the status is not ok.
Fix string `json:"fix,omitempty"`
}
Check is one line of the doctor's report.
type Report ¶
Report is what the doctor found. Ready means the server can start against this database as it is.
func Doctor ¶
Doctor examines the database the way the server will use it: reachable, PostgreSQL 13 or newer, the pgvector extension present on the server, new enough, created in this database, and this role allowed to create tables. With fix it creates the extension when the server has it and the role may. The report comes back whatever is found; the error is for failures of the examination itself.