-
Notifications
You must be signed in to change notification settings - Fork 0
Add configurable PostgreSQL schema for backwards compatibility #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add configurable PostgreSQL schema for backwards compatibility #10
Conversation
Co-authored-by: warengonzaga <[email protected]>
Co-authored-by: warengonzaga <[email protected]>
Co-authored-by: warengonzaga <[email protected]>
…nstructor Co-authored-by: warengonzaga <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds configurable PostgreSQL schema support to enable backwards compatibility with existing applications (Telegram bots, Discord bots) using different table and column naming conventions. The implementation maintains strong defaults (nuvex_storage, nuvex_key, nuvex_data) while allowing customization through an optional schema configuration object.
Key Changes:
- Introduced
PostgresSchemaConfiginterface with optionaltableNameandcolumnsconfiguration - Enhanced
PostgresStorageto extract, validate, and use dynamic schema identifiers in all SQL operations - Added
validateSQLIdentifier()function with strict regex validation (^[a-zA-Z_][a-zA-Z0-9_]*$) to prevent SQL injection - Updated database utilities (
generateNuvexSchemaSQL,setupNuvexSchema,cleanupExpiredEntries,dropNuvexSchema) to support custom schemas
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/types/index.ts | Defines PostgresSchemaConfig interface and integrates it with PostgresConfig for optional schema customization |
| src/layers/postgres.ts | Extracts schema config in constructor, validates all identifiers, and uses dynamic table/column names in all SQL queries |
| src/core/database.ts | Implements validateSQLIdentifier() for security, generateNuvexSchemaSQL() for dynamic DDL generation, and adds schema parameter support to all utility functions |
| src/tests/unit/postgres-schema.test.ts | Comprehensive tests for schema configuration including SQL injection prevention, custom naming, and partial configuration scenarios |
| src/tests/unit/database.test.ts | Updates existing schema SQL tests to verify new default column names (nuvex_key, nuvex_data) |
| README.md | Documents schema configuration with examples for default, Telegram bot, and Discord bot compatibility scenarios |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…s, and dropNuvexSchema Co-authored-by: warengonzaga <[email protected]>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
…ndling Co-authored-by: warengonzaga <[email protected]>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot what's the issue with snyk in our test? |
The Snyk errors during This doesn't affect the test results - all 127 tests pass successfully. Snyk is a security scanning tool listed as a dev dependency, but it's not required for running Jest tests. The install completes successfully despite the Snyk download failure. If Snyk scanning is needed, it should be run separately via |
c31e0ef
into
copilot/refactor-3-layer-storage
…, and L3-first writes (#6) * Initial plan * Create modular layer architecture with LRU, health checks, and comprehensive documentation Co-authored-by: warengonzaga <[email protected]> * Refactor StorageEngine to use modular layers with L3-first write and Promise.allSettled Co-authored-by: warengonzaga <[email protected]> * Fix tests and skip tests requiring keys() reimplementation Co-authored-by: warengonzaga <[email protected]> * Address code review feedback: fix ping() type safety and document keys() limitations Co-authored-by: warengonzaga <[email protected]> * ✨️ tweak: add configurable PostgreSQL schema for backwards compatibility (#10) * Initial plan * Add configurable schema types and update PostgresStorage layer Co-authored-by: warengonzaga <[email protected]> * Add tests and documentation for configurable schema Co-authored-by: warengonzaga <[email protected]> * Add SQL injection prevention for configurable schema identifiers Co-authored-by: warengonzaga <[email protected]> * Export validateSQLIdentifier and add validation in PostgresStorage constructor Co-authored-by: warengonzaga <[email protected]> * Add tests for custom schema in setupNuvexSchema, cleanupExpiredEntries, and dropNuvexSchema Co-authored-by: warengonzaga <[email protected]> * Add edge case tests for identifier validation and fix empty string handling Co-authored-by: warengonzaga <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: warengonzaga <[email protected]> * 🔧 update(postgres): ensure connection state is updated on disconnect * 🔧 update(engine): enhance error handling and usage recommendations for set() * 📖 docs: enhance increment method documentation with concurrency warnings * ⚙️ setup: add Snyk Security Extension AI rules instructions --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: warengonzaga <[email protected]> Co-authored-by: Waren Gonzaga <[email protected]>
Task: Add Configurable PostgreSQL Storage Schema
Implementation plan for adding configurable table and column names to PostgreSQL storage layer.
Progress Checklist
PostgresSchemaConfigtype tosrc/types/index.tsPostgresConfigto accept optionalschemaconfigurationPostgresStorageclass to use dynamic table/column namesget()method with dynamic column/table namesset()method with dynamic column/table namesdelete()method with dynamic column/table namesexists()method with dynamic column/table namesclear()method with dynamic column/table namessrc/core/database.tsto support configurable schemasetupNuvexSchemaaccept schema configurationSummary
Successfully implemented configurable PostgreSQL schema with:
nuvex_storagetable withnuvex_keyandnuvex_datacolumnsOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.