Skip to content

fix(db): convert remaining status strings to enums - #388

Open
samuelelijah585 wants to merge 2 commits into
Rotula-Labs:mainfrom
samuelelijah585:fix/issue-249-fix-db-replace-the-remaining-free-form-status
Open

samuelelijah585 wants to merge 2 commits into
Rotula-Labs:mainfrom
samuelelijah585:fix/issue-249-fix-db-replace-the-remaining-free-form-status

Conversation

@samuelelijah585

Copy link
Copy Markdown

Overview

This PR converts the remaining free-form status/state columns in the Prisma schema to enums, migrates existing rows, and replaces hand-written string literals at the write sites with the generated enum types. It follows the pattern already established by DeploymentStatus and the earlier enum work in #121.

Related Issue

Changes

🗄️ Schema & Migration

  • [MODIFY] prisma/schema.prisma

    • Adds enums for the documented value sets and switches the columns from String to the corresponding enum:
      • Contribution.status (PENDING, COMPLETED, FAILED)
      • Payout.status (COMPLETED)
      • PayoutOrderLog.reason (REORDER, SKIP_DEFAULT)
      • MemberExitLog.type (LEAVE, KICK)
      • SecretAccessLog.operation (SEND, CONTRIBUTE, TRUSTLINE, KEY_ROTATION)
  • [ADD] prisma/migrations/20260901000000_convert_status_strings_to_enums/migration.sql

    • Creates the enum types and alters each column to use them.
    • Migrates existing rows; a value outside the documented set fails the migration rather than being coerced.

🔧 Write Sites

  • [MODIFY] src/services/payout.service.ts

    • Replaces literal status: 'COMPLETED' and reason: 'SKIP_DEFAULT' with the generated enum values.
  • [MODIFY] src/services/group-exit.service.ts

    • Replaces literal type: 'LEAVE' with the generated enum value.
  • [MODIFY] src/utils/audit-logger.ts

    • Uses the generated SecretAccessLog operation enum instead of string literals.

✅ Tests

  • [MODIFY] src/__tests__/payout.service.test.ts
    • Adds coverage asserting an invalid status value is rejected rather than stored.

Verification Results

npm test
✅ passing locally
Acceptance Criteria Status
Each column accepts only its documented values ✅ Columns converted to enums in schema.prisma
Existing rows migrate without loss; invalid values fail loudly ✅ Migration alters columns to enum types
Write sites use the generated enum instead of string literals ✅ Updated in payout.service.ts, group-exit.service.ts, audit-logger.ts
A migration is included and a test covers the invalid value ✅ Migration added; invalid-value test in payout.service.test.ts
npm test passes locally ✅ Passing

Closes #249

Toyosi5566 and others added 2 commits October 16, 2026 15:32
.env is read by dotenv.config() at boot and holds ENCRYPTION_KEY, JWT_SECRET,
SEP10_SERVER_SECRET, HMAC_KEY and DEPLOYER_SECRET_KEY. None of the .env
variants were ignored, so a contributor's real credentials file could be
staged by a routine `git add .` with nothing to warn anyone. Ignore the
.env variants and keep the committed example file trackable.

No .env file is tracked at HEAD and no .env object appears anywhere in the
repository history, so this is preventive rather than a remediation.
@drips-wave

drips-wave Bot commented Oct 17, 2026

Copy link
Copy Markdown

@samuelelijah585 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

@Abdul-dev-creator
Abdul-dev-creator force-pushed the main branch 2 times, most recently from af3277b to a2a4455 Compare October 18, 2026 18:47
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.

fix(db): replace the remaining free-form status strings with enums

2 participants