Skip to content

feat(presets): postgres-pgvector preset + dynamic DB picker#392

Open
geodro wants to merge 1 commit into
mainfrom
feat/postgres-pgvector
Open

feat(presets): postgres-pgvector preset + dynamic DB picker#392
geodro wants to merge 1 commit into
mainfrom
feat/postgres-pgvector

Conversation

@geodro
Copy link
Copy Markdown
Owner

@geodro geodro commented May 19, 2026

Adds the postgres-pgvector preset (v18 canonical, plus v17 and v16 alternates) so users wanting vector embeddings can install it as a first-class lerd service instead of hand-rolling a custom yaml. The image is pgvector/pgvector:pg, no PostGIS, host ports 5518/5517/5516 to avoid colliding with the default postgres preset.

While wiring it up, three rough edges around the postgres-family code paths needed fixing for pgvector to behave like every other DB family alternate. First, config.InferFamily only matches the - shape, so postgres-pgvector returned an empty family and cli/env.go decided it was not a database, skipping DB_DATABASE rewrite and createDatabase. Second, the env wizard and the MCP db_set tool hardcoded a sqlite/mysql/postgres choice, so pgvector was invisible to the pick UX even once installed. Third, the multi-version preset picker filtered the canonical version out, so users staring at the postgres-pgvector row saw only v17 and v16 in the dropdown with no obvious way to install v18.

Family resolution is now a single helper. config.FamilyOf(*CustomService) and config.FamilyOfName(string) prefer the explicit Family field over name-pattern inference, and the four sites that used to inline the same Family-then-InferFamily dance (serviceops/migrate.go, serviceops/serviceops.go, cli/init.go, plus the new env-side check) now route through it. config.IsDBServiceName is the same idea for the boolean "does this name refer to a DB" used by db_set validation and ReplaceProjectDBService.

The env wizard and db_set both build their option list dynamically from ServicesInFamily("mysql") + ServicesInFamily("postgres") + sqlite, so any installed family alternate (mariadb, mysql-5-7, postgres-pgvector, future ones) shows up by name. Picking pgvector in .lerd.yaml now correctly suppresses the default postgres preset via userPickedDBFromYAML and lands the right env_vars and DB creation in pgvector's container.

The preset picker dropdown gains canonical versions, marked (default) in the label and preselected via default_version. A new config.PresetVersionServiceName helper centralises the canonical-vs-suffixed name resolution so the CLI table, web UI handler, and MCP list all check install state through the same path. An installed canonical now correctly shows up in installed_tags and disappears from the dropdown the same way installed alternates always did, leaving only what the user can still install.

lerd-postgres-pgvector (and its alternates) participate in pgadmin auto-discovery via discover_family:postgres without any pgadmin-side change. There is no env_detect on the preset on purpose: DB_CONNECTION=pgsql already belongs to the default postgres detector, so first-clone auto-detection would require a tiebreaker we have not designed. The intended UX is install once via lerd service preset postgres-pgvector, pick once via wizard or db_set or .lerd.yaml, every subsequent lerd env re-run routes everything through pgvector.

Refs #378.

Adds the postgres-pgvector preset (v18 canonical, plus v17 and v16 alternates) so users wanting vector embeddings can install it as a first-class lerd service instead of hand-rolling a custom yaml. The image is pgvector/pgvector:pg<N>, no PostGIS, host ports 5518/5517/5516 to avoid colliding with the default postgres preset.

While wiring it up, three rough edges around the postgres-family code paths needed fixing for pgvector to behave like every other DB family alternate. First, config.InferFamily only matches the <family>-<digit> shape, so postgres-pgvector returned an empty family and cli/env.go decided it was not a database, skipping DB_DATABASE rewrite and createDatabase. Second, the env wizard and the MCP db_set tool hardcoded a sqlite/mysql/postgres choice, so pgvector was invisible to the pick UX even once installed. Third, the multi-version preset picker filtered the canonical version out, so users staring at the postgres-pgvector row saw only v17 and v16 in the dropdown with no obvious way to install v18.

Family resolution is now a single helper. config.FamilyOf(*CustomService) and config.FamilyOfName(string) prefer the explicit Family field over name-pattern inference, and the four sites that used to inline the same Family-then-InferFamily dance (serviceops/migrate.go, serviceops/serviceops.go, cli/init.go, plus the new env-side check) now route through it. config.IsDBServiceName is the same idea for the boolean "does this name refer to a DB" used by db_set validation and ReplaceProjectDBService.

The env wizard and db_set both build their option list dynamically from ServicesInFamily("mysql") + ServicesInFamily("postgres") + sqlite, so any installed family alternate (mariadb, mysql-5-7, postgres-pgvector, future ones) shows up by name. Picking pgvector in .lerd.yaml now correctly suppresses the default postgres preset via userPickedDBFromYAML and lands the right env_vars and DB creation in pgvector's container.

The preset picker dropdown gains canonical versions, marked (default) in the label and preselected via default_version. A new config.PresetVersionServiceName helper centralises the canonical-vs-suffixed name resolution so the CLI table, web UI handler, and MCP list all check install state through the same path. An installed canonical now correctly shows up in installed_tags and disappears from the dropdown the same way installed alternates always did, leaving only what the user can still install.

lerd-postgres-pgvector (and its alternates) participate in pgadmin auto-discovery via discover_family:postgres without any pgadmin-side change. There is no env_detect on the preset on purpose: DB_CONNECTION=pgsql already belongs to the default postgres detector, so first-clone auto-detection would require a tiebreaker we have not designed. The intended UX is install once via lerd service preset postgres-pgvector, pick once via wizard or db_set or .lerd.yaml, every subsequent lerd env re-run routes everything through pgvector.

Refs #378.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant