Skip to content

feat: implement postgres db as storage#76

Open
zdravko61 wants to merge 7 commits intoTHCLab:masterfrom
VereignAG:feat/impl-pg-db
Open

feat: implement postgres db as storage#76
zdravko61 wants to merge 7 commits intoTHCLab:masterfrom
VereignAG:feat/impl-pg-db

Conversation

@zdravko61
Copy link

@zdravko61 zdravko61 commented Mar 26, 2026

Implements the abstract storage traits (EventDatabase, LogDatabase, SequencedEventDatabase, EscrowDatabase) introduced in the new feature-flagged dual-mode storage architecture (#69), adding PostgreSQL as alternative to the redb backend.

  • Add storage-postgres feature flag with SQLx + async-std dependencies
  • Implement PostgresDatabase with full KEL, escrow, and KSN support
  • Add SQL migrations for all KERI tables
  • Use async_std::task::block_on to bridge async SQLx with the sync trait API
  • Gate postgres module behind `#[cfg(feature = "storage-postgres")]

Running the tests

docker run -d -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=keri_test -p 5432:5432 postgres:18

then

DATABASE_URL=postgres://postgres:postgres@localhost:5432/keri_test cargo test -p keri-core --features storage-postgres -- --ignored

seriouscoderone and others added 4 commits February 18, 2026 17:47
…tecture

Gate redb behind `storage-redb` feature flag (default ON) in keri-core and
teliox so the core protocol logic can compile and run without redb. This
enables future alternative storage backends (e.g., DynamoDB for serverless).

Key changes:
- Split EventStorage constructors: generic `new()` (no mailbox) vs
  `new_redb()` (RedbDatabase with mailbox) vs `new_with_mailbox()` (inject)
- Make mailbox_data an Option<MailboxData> to support non-redb backends
- Remove Any bound from EventValidator
- Gate TelLogDatabase, teliox EscrowDatabase, and escrow module behind
  storage-redb feature
- Genericize teliox escrow structs over K: EventDatabase for KEL storage
- Add in-memory MemoryDatabase implementing all database traits for
  validation and testing
- Move rkyv_adapter to database::rkyv_adapter (not under database::redb)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Introduce `storage-postgres` feature and dependencies
- Implement PostgresDatabase, log, escrow, and KSN log modules
- Add SQL migrations for all KERI tables
- Integrate with existing database traits and event flows

Signed-off-by: Zdravko Iliev <zdravko.iliev@vereign.com>
Signed-off-by: Zdravko Iliev <zdravko.iliev@vereign.com>
@zdravko61 zdravko61 changed the title Feat/impl pg db draft: implement postgres db as storage Mar 26, 2026
@zdravko61 zdravko61 closed this Mar 26, 2026
@zdravko61 zdravko61 reopened this Mar 26, 2026
@zdravko61 zdravko61 changed the title draft: implement postgres db as storage feat: implement postgres db as storage Mar 26, 2026
Signed-off-by: Zdravko Iliev <zdravko.iliev@vereign.com>
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.

2 participants