feat(presets): postgres-pgvector preset + dynamic DB picker#392
Open
geodro wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.