Cleanup legacy schema - #1306
Merged
Merged
Conversation
Merging the API-credential work put drop-legacy-schema at the same number as create-api-credentials. Its own guard only passes once the credential migration script has revoked the legacy api_keys rows, so it has to sort last. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Renumber the credential migrations off the 055 collision with create-financial-operations, and keep creation ordered before the quote-tickets foreign key. Drop code the credential refactor left unreachable: the partnerName quote attribution path and its publicKey pricing source, the session branch in webhook ownership (those routes carry no session middleware), the MAX_ACTIVE_KEYS_PER_USER alias, the keyId route param, and the unused DELETE body option in the dashboard client. Harden the migration preflight the runbook already specified: reject inactive partners and past expiries. Only reconcile an existing Auth identity when Supabase reports a duplicate email, so an outage or rate limit no longer surfaces as a conflict after a full-directory scan. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
✅ Deploy Preview for vortex-sandbox ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for vrtx-dashboard canceled.
|
✅ Deploy Preview for vortexfi ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
# Conflicts: # apps/api/src/api/controllers/brla.controller.test.ts # apps/api/src/api/controllers/brla.controller.ts # apps/api/src/api/controllers/userApiKeys.controller.ts # docs/plans/api-credential-unification.md
Six Avenia endpoints and ramp-time account resolution still authorized against the single entity resolved by getOrCreateCustomerEntityForProfile, denying rightful owners whenever their record lives on a non-active entity (migration 040 folds, or an individual row after a business account-type selection). Ownership now spans every entity the profile owns, matching the sites converted earlier; resolution prefers the active entity's account when several are approved. Includes a read-only production audit script sizing the affected population. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…schema The identity architecture document still described the retired api_keys two-axis model; it now reflects api_credentials (required subject profile, optional attributing partner) and partner-managed profiles. The cleanup report referenced two documents deleted by the docs consolidation and now records the completed Avenia profile-wide ownership scoping with its audit script. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Cleans up legacy schema while moving identity, credentials, provider accounts, and pricing to canonical models.
Changes:
- Adds irreversible legacy-schema migrations and deployment audit tooling.
- Hardens credential, partner, Avenia, and AlfredPay behavior.
- Updates dashboard history/amount formatting and related documentation/tests.
Reviewed changes
Copilot reviewed 69 out of 73 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
docs/security-spec/README.md |
Renames credential-auth specification. |
docs/security-spec/07-operations/api-surface.md |
Updates API security invariants. |
docs/security-spec/05-integrations/brla.md |
Documents canonical Avenia identity. |
docs/security-spec/05-integrations/alfredpay.md |
Documents usage and legacy deletion. |
docs/security-spec/03-ramp-engine/quote-lifecycle.md |
Documents uncached limit enforcement. |
docs/security-spec/03-ramp-engine/profile-partner-pricing.md |
Removes legacy assignment references. |
docs/security-spec/01-auth/api-keys.md |
Updates unified credential behavior. |
docs/product-dashboard.md |
Documents initial-ramp omission. |
docs/plans/legacy-schema-cleanup-temporary-report.md |
Adds cleanup deployment report. |
docs/operations-testing.md |
Updates canonical test factories. |
docs/architecture-identity-model.md |
Updates identity architecture. |
docs/api/pages/04-ramp-lifecycle.md |
Clarifies ramp-info authentication. |
docs/api/pages/03-authentication-and-partner-keys.md |
Updates credential capability matrix. |
docs/api/openapi/vortex.openapi.json |
Updates API authentication contract. |
docs/api/openapi/vortex.openapi.d.ts |
Regenerates OpenAPI types. |
apps/dashboard/src/services/api/transaction.mappers.ts |
Omits initial ramps. |
apps/dashboard/src/services/api/transaction.mappers.test.ts |
Tests history filtering. |
apps/dashboard/src/services/api/api-client.ts |
Removes DELETE request bodies. |
apps/dashboard/src/routes/_app/transactions.tsx |
Removes row-level resume state. |
apps/dashboard/src/lib/amount.ts |
Centralizes amount formatting. |
apps/dashboard/src/lib/amount.test.ts |
Tests amount formatting. |
apps/dashboard/src/components/transfer/TransferForm.tsx |
Formats and clamps transfer amounts. |
apps/dashboard/src/components/transfer/QuoteSummary.tsx |
Formats quote values. |
apps/dashboard/src/components/transfer/OnrampPaymentInstructions.tsx |
Formats payment amounts. |
apps/dashboard/src/components/transfer/OnrampForm.tsx |
Formats onramp outputs. |
apps/dashboard/src/components/transfer/FundingMethods.tsx |
Formats balances and requirements. |
apps/dashboard/src/components/transactions/TransactionsTable.tsx |
Formats amounts and removes resume action. |
apps/dashboard/src/components/quote/QuoteExplorer.tsx |
Applies display precision. |
apps/dashboard/src/components/quote/AmountPanel.tsx |
Reuses shared locale settings. |
apps/dashboard/src/components/limits/LimitsCard.tsx |
Uses shared formatter. |
apps/dashboard/e2e/transactions.spec.ts |
Tests formatting and hidden ramps. |
apps/dashboard/e2e/quote-explorer.spec.ts |
Updates precision expectations. |
apps/api/src/test-utils/factories.ts |
Clarifies canonical Avenia factory. |
apps/api/src/models/taxId.model.ts |
Removes legacy TaxId model. |
apps/api/src/models/profilePartnerAssignment.model.ts |
Removes directional partner fields. |
apps/api/src/models/profilePartnerAssignment.model.test.ts |
Verifies legacy fields are absent. |
apps/api/src/models/index.ts |
Removes legacy model associations. |
apps/api/src/models/apiKey.model.ts |
Removes legacy partner-name field. |
apps/api/src/database/migrations/060-drop-legacy-schema.ts |
Drops legacy schema irreversibly. |
apps/api/src/database/migrations/059-add-api-credential-id-to-quote-tickets.ts |
Attributes quotes to credentials. |
apps/api/src/database/migrations/058-create-partner-managed-profiles.ts |
Creates managed-profile associations. |
apps/api/src/database/migrations/057-create-api-credentials.ts |
Creates unified credential storage. |
apps/api/src/api/services/quote/index.ts |
Removes partner-name context. |
apps/api/src/api/services/quote/core/types.ts |
Simplifies pricing-source types. |
apps/api/src/api/services/quote/core/quote-context.ts |
Removes legacy request metadata. |
apps/api/src/api/services/quote/core/partner-resolution.ts |
Resolves canonical partners. |
apps/api/src/api/services/quote/core/partner-resolution.test.ts |
Updates partner-resolution tests. |
apps/api/src/api/services/phases/blocks/core/validation.ts |
Uses uncached enforcement usage. |
apps/api/src/api/services/managed-profile.service.ts |
Distinguishes duplicate-email failures. |
apps/api/src/api/services/managed-profile.service.test.ts |
Updates duplicate-email mock. |
apps/api/src/api/services/limits.service.ts |
Uses informational usage calculation. |
apps/api/src/api/services/limits.service.test.ts |
Updates entity mocks. |
apps/api/src/api/services/avenia-account.ts |
Resolves accounts profile-wide. |
apps/api/src/api/services/avenia-account.test.ts |
Tests multi-entity resolution. |
apps/api/src/api/services/api-credential-migration.test.ts |
Updates legacy migration fixtures. |
apps/api/src/api/services/alfredpay/alfredpay.helpers.ts |
Separates reporting and enforcement. |
apps/api/src/api/services/alfredpay/alfredpay.helpers.test.ts |
Tests both usage paths. |
apps/api/src/api/routes/v1/index.ts |
Updates credential-route documentation. |
apps/api/src/api/routes/v1/admin/partner-api-keys.route.ts |
Documents subject-bound credentials. |
apps/api/src/api/middlewares/publicKeyAuth.test.ts |
Tests inactive-partner rejection. |
apps/api/src/api/middlewares/apiKeyAuth.helpers.ts |
Requires active credential partners. |
apps/api/src/api/controllers/webhook.controller.ts |
Derives webhook credential ownership. |
apps/api/src/api/controllers/userApiKeys.controller.ts |
Simplifies credential revocation. |
apps/api/src/api/controllers/userApiKeys.controller.test.ts |
Updates revocation typing. |
apps/api/src/api/controllers/quote.controller.ts |
Uses credential partner attribution. |
apps/api/src/api/controllers/brla.controller.ts |
Removes TaxId adoption and broadens ownership scope. |
apps/api/src/api/controllers/brla.controller.test.ts |
Tests canonical profile-wide behavior. |
apps/api/scripts/schema-parity-checks.sql |
Adds fail-closed migration checks. |
apps/api/scripts/reconcile-unmigrated-avenia-status.ts |
Adds provider reconciliation tooling. |
apps/api/scripts/export-unmigrated-avenia-customers.sql |
Exports legacy-only Avenia accounts. |
apps/api/scripts/audit-avenia-entity-scope.sql |
Audits entity-scope mismatches. |
apps/api/scripts/api-credential-migration.ts |
Validates expiry and active partners. |
.agents/skills/vortex-integration/SKILL.md |
Updates ramp-info integration guidance. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The credential migrations renumbered in this PR (055/057/058 -> 057/058/059) were already applied under their old names on staging and developer databases. Without reconciliation umzug treats the renamed files as pending and re-runs them; they only survive by CREATE TABLE IF NOT EXISTS plus the migrator's error swallowing, and SequelizeMeta is left with stale old-name rows alongside the new ones. Rename the applied entries before umzug computes the pending list; a migration cannot do this because pending is resolved before execution.
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.
Summary