Skip to content

Feat/postgres quota request store - #1659

Open
devogechukwu wants to merge 2 commits into
CalloraOrg:mainfrom
devogechukwu:feat/postgres-quota-request-store
Open

devogechukwu wants to merge 2 commits into
CalloraOrg:mainfrom
devogechukwu:feat/postgres-quota-request-store

Conversation

@devogechukwu

Copy link
Copy Markdown

Summary

Persist developer quota increase requests in PostgreSQL by adding a quota_requests migration, implementing PostgresQuotaRequestStore, and wiring getQuotaRequestStore() to select it when PostgreSQL is configured.

Changes

  • Migration (migrations/0033_quota_requests.sql & .down.sql):
    • Adds quota_requests table with id, developer_id, requested_tier, reason, monthly_call_limit, rate_limit_max_requests, status (CHECK constraint for pending | approved | rejected), admin_notes, created_at, resolved_at, and resolved_by.
    • Adds indexes on (developer_id) and (status, created_at).
  • PostgresQuotaRequestStore (src/services/postgresQuotaRequestStore.ts):
    • Implements create, findById, list, and update with parameterized SQL.
    • update only touches provided fields and returns undefined when the ID does not exist.
    • Omits optional fields (requestedOverrides, adminNotes, resolvedAt, resolvedBy) when NULL to preserve existing HTTP response shapes.
  • Store selection & cache invalidation (src/services/quotaService.ts):
    • getQuotaRequestStore() selects PostgresQuotaRequestStore when DATABASE_URL is configured outside demo and test modes, keeping InMemoryQuotaRequestStore as the test/demo default.
    • Added resetQuotaRequestStore() helper and ensured bulkUpdateQuotaRequests invalidates quotasCache.
  • Tests (src/services/postgresQuotaRequestStore.test.ts):
    • Runs the shared store contract against both InMemoryQuotaRequestStore and PostgresQuotaRequestStore (via pg-mem), plus persistence-across-restart and double-resolve conflict tests.

Notes

  • Local node_modules was not installed in this environment, so jest / tsc could not be executed locally; CI will run the full test suite, typecheck, and migration checks.

Closes #1561

@drips-wave

drips-wave Bot commented Nov 23, 2026

Copy link
Copy Markdown

@devogechukwu Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

Persist developer quota requests in Postgres

1 participant