Skip to content

Comments

feat(vdb): support custom schema for PGVector#31243

Open
kenwoodjw wants to merge 5 commits intolanggenius:mainfrom
kenwoodjw:feat/pgvector-custom-schema
Open

feat(vdb): support custom schema for PGVector#31243
kenwoodjw wants to merge 5 commits intolanggenius:mainfrom
kenwoodjw:feat/pgvector-custom-schema

Conversation

@kenwoodjw
Copy link
Contributor

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

Fixes #31242

Screenshots

Before After
... ...

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint and make type-check (backend) and cd web && npx lint-staged (frontend) to appease the lint gods

@kenwoodjw kenwoodjw requested a review from JohnJyong as a code owner January 19, 2026 15:29
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jan 19, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @kenwoodjw, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the flexibility and manageability of PGVector integration by introducing support for custom PostgreSQL schemas. This allows users to organize their vector data within dedicated database schemas rather than the default 'public' schema, which is particularly beneficial for multi-tenant environments or for maintaining a cleaner database structure. The changes ensure that all interactions with PGVector tables are properly namespaced, improving data isolation and administrative control.

Highlights

  • Custom PostgreSQL Schema Support: Introduced a new configuration option PGVECTOR_SCHEMA to allow users to specify a custom PostgreSQL schema for PGVector tables, defaulting to 'public'.
  • Automatic Schema Creation: Implemented automatic schema creation: The system will now check if the specified schema exists and create it if it doesn't, ensuring proper isolation and organization of vector data.
  • Schema-Aware Database Operations: Updated all PGVector database operations (e.g., INSERT, SELECT, DELETE, DROP TABLE, index creation) to correctly utilize the configured custom schema, ensuring data is stored and accessed within the intended namespace.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@dosubot dosubot bot added the 👻 feat:rag Embedding related issue, like qdrant, weaviate, milvus, vector database. label Jan 19, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for custom schemas in PGVector, which is a great feature. The implementation correctly introduces a new configuration for the schema name and updates the relevant parts of the code to use it.

My review includes two main points of feedback for api/core/rag/datasource/vdb/pgvector/pgvector.py:

  1. The new _ensure_schema_exists method has a race condition and uses an unsafe f-string for a CREATE SCHEMA query. I've suggested a more robust implementation using a Redis lock and psycopg2.sql for safety.
  2. The construction of full_table_name does not quote the schema and table names, which will lead to SQL errors if they contain special characters. I've provided a suggestion to fix this while keeping the index_hash logic consistent.

Additionally, it appears the unit and integration tests for PGVector have not been updated to include the new schema_name in the PGVectorConfig. This will likely cause the tests to fail. Please update the tests to reflect the changes.

Signed-off-by: kenwoodjw <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

👻 feat:rag Embedding related issue, like qdrant, weaviate, milvus, vector database. size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(vdb): support custom schema for PGVector

1 participant