Skip to content

feat: add atomic DB transactions for streams + audit + webhooks#200

Merged
Jagadeeshftw merged 2 commits into
Fluxora-Org:mainfrom
marvelousufelix:feat/db-transactions-streams-audit-webhooks
Apr 24, 2026
Merged

feat: add atomic DB transactions for streams + audit + webhooks#200
Jagadeeshftw merged 2 commits into
Fluxora-Org:mainfrom
marvelousufelix:feat/db-transactions-streams-audit-webhooks

Conversation

@marvelousufelix
Copy link
Copy Markdown
Contributor

Closes #157

  • streamRepository: add transactionalUpsertStream() and transactionalUpdateStream() each wraps stream write, audit_logs row, and optional webhook_outbox row in a single SQLite transaction; rolls back all three on any failure

  • auditLog: add buildAuditEntry() + writeAuditEntryToDb() for the transactional write path; replace better-sqlite3 type import with local AuditDbConnection interface; expand AuditAction union to cover STREAM_UPDATED, STREAM_STATUS_UPDATED, PAUSE_FLAGS_UPDATED, REINDEX_TRIGGERED

  • migrations: add audit_logs + webhook_outbox tables for both SQLite (001_create_streams_table.ts) and PostgreSQL (1774715200000_audit-and-webhook-outbox.ts)

  • tests: 25 tests across 9 suites covering atomic commit, rollback on stream/audit/webhook failure, idempotent upsert, invalid status transitions, decimal-string precision, and sequential transactions

Decimal-string amounts are preserved as TEXT throughout never converted to numbers ensuring full Stellar precision (7 dp) across the chain -> DB -> API boundary.

- streamRepository: add transactionalUpsertStream() and
  transactionalUpdateStream()  each wraps stream write, audit_logs
  row, and optional webhook_outbox row in a single SQLite transaction;
  rolls back all three on any failure

- auditLog: add buildAuditEntry() + writeAuditEntryToDb() for the
  transactional write path; replace better-sqlite3 type import with
  local AuditDbConnection interface; expand AuditAction union to cover
  STREAM_UPDATED, STREAM_STATUS_UPDATED, PAUSE_FLAGS_UPDATED,
  REINDEX_TRIGGERED

- migrations: add audit_logs + webhook_outbox tables for both SQLite
  (001_create_streams_table.ts) and PostgreSQL
  (1774715200000_audit-and-webhook-outbox.ts)

- tests: 25 tests across 9 suites covering atomic commit, rollback on
  stream/audit/webhook failure, idempotent upsert, invalid status
  transitions, decimal-string precision, and sequential transactions

Decimal-string amounts are preserved as TEXT throughout  never
converted to numbers  ensuring full Stellar precision (7 dp) across
the chain -> DB -> API boundary.
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 23, 2026

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

@Jagadeeshftw Jagadeeshftw merged commit 4925bb7 into Fluxora-Org:main Apr 24, 2026
1 check failed
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.

Use DB transactions for multi-step operations that touch streams + audit + webhooks

2 participants