Skip to content

Cleanup legacy schema - #1306

Merged
gianfra-t merged 19 commits into
stagingfrom
cleanup-legacy-schema
Aug 5, 2026
Merged

Cleanup legacy schema#1306
gianfra-t merged 19 commits into
stagingfrom
cleanup-legacy-schema

Conversation

@gianfra-t

@gianfra-t gianfra-t commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Removes legacy provider, KYC, partner-pricing, and API-key schema via an irreversible migration.
  • Moves Avenia account resolution and ownership checks fully onto canonical profile entities, with reconciliation/audit tooling.
  • Hardens credential validation, partner scoping, quote attribution, and AlfredPay limit enforcement.
  • Improves dashboard amount formatting and hides unstarted ramps from transaction history.
  • Updates tests, OpenAPI definitions, and security/architecture documentation.

gianfra-t and others added 8 commits July 31, 2026 13:18
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>
@netlify

netlify Bot commented Aug 3, 2026

Copy link
Copy Markdown

Deploy Preview for vortex-sandbox ready!

Name Link
🔨 Latest commit 1237886
🔍 Latest deploy log https://app.netlify.com/projects/vortex-sandbox/deploys/6a730201a3515700085d0484
😎 Deploy Preview https://deploy-preview-1306--vortex-sandbox.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Aug 3, 2026

Copy link
Copy Markdown

Deploy Preview for vrtx-dashboard canceled.

Name Link
🔨 Latest commit 1237886
🔍 Latest deploy log https://app.netlify.com/projects/vrtx-dashboard/deploys/6a7302010a797a0008cdd53f

@netlify

netlify Bot commented Aug 3, 2026

Copy link
Copy Markdown

Deploy Preview for vortexfi ready!

Name Link
🔨 Latest commit 1237886
🔍 Latest deploy log https://app.netlify.com/projects/vortexfi/deploys/6a7302018dcc650009fc61bd
😎 Deploy Preview https://deploy-preview-1306--vortexfi.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

gianfra-t and others added 8 commits August 3, 2026 18:02
# 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>
@gianfra-t gianfra-t changed the title [WIP] Cleanup legacy schema Cleanup legacy schema Aug 4, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread apps/api/src/database/migrations/060-drop-legacy-schema.ts
Comment thread apps/dashboard/src/components/transfer/TransferForm.tsx Outdated
Comment thread docs/security-spec/05-integrations/brla.md Outdated
Comment thread docs/plans/legacy-schema-cleanup-temporary-report.md Outdated
Comment thread apps/api/scripts/reconcile-unmigrated-avenia-status.ts
Comment thread apps/api/src/database/migrations/060-drop-legacy-schema.ts
Comment thread apps/dashboard/src/components/quote/QuoteExplorer.tsx Outdated
Comment thread apps/api/src/api/services/managed-profile.service.ts
gianfra-t and others added 2 commits August 4, 2026 17:20
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.
@gianfra-t
gianfra-t merged commit 6600c81 into staging Aug 5, 2026
6 checks passed
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.

3 participants