Skip to content

feat(db): Phase 2 PostgreSQL backend for zeph-db#2372

Merged
bug-ops merged 1 commit intomainfrom
feat/m28/db-abstraction-phase2
Mar 28, 2026
Merged

feat(db): Phase 2 PostgreSQL backend for zeph-db#2372
bug-ops merged 1 commit intomainfrom
feat/m28/db-abstraction-phase2

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Mar 28, 2026

Summary

  • Add 52 PostgreSQL migration files (crates/zeph-db/migrations/postgres/) — full DDL translation from SQLite schema
  • Extend Dialect trait with EPOCH_NOW constant and epoch_from_col() method; replace all #[cfg]-gated epoch SQL in consumers
  • Add FTS abstraction in fts.rs: 6 helper functions covering SQLite FTS5 and PostgreSQL tsvector/GIN patterns
  • Add is_postgres_url() bootstrap guard: runtime error when postgres URL passed to SQLite build
  • Add database_url config field + ZEPH_DATABASE_URL vault key resolution
  • Fix bytemuck alignment bug in db_vector_store.rs and response_cache.rs: replace cast_slice with explicit to_le_bytes()/from_le_bytes(); remove bytemuck from zeph-memory
  • Add #[cfg(feature = "test-utils")] integration tests with testcontainers (tests/postgres_integration.rs)

Test plan

  • cargo check -p zeph-db (sqlite default)
  • cargo check -p zeph-db --no-default-features --features postgres
  • cargo nextest run --workspace --lib --bins — all unit tests pass
  • cargo nextest run -p zeph-db --features test-utils -- --ignored — requires Docker; runs 4 postgres integration tests
  • Verify no AUTOINCREMENT/WITHOUT ROWID/SQLite-isms in migrations/postgres/

- 52 PostgreSQL migration files with full DDL translation (BIGSERIAL,
  TIMESTAMPTZ, BYTEA, BOOLEAN, tsvector/GIN for FTS, plpgsql triggers)
- Dialect::EPOCH_NOW constant and epoch_from_col() method for portable
  epoch extraction across backends
- FTS helper functions in fts.rs covering all 5 query patterns: basic
  search, ranked search (ts_rank with weight arrays), prefix search,
  graph entity FTS, and ORDER BY direction (ASC/DESC per backend)
- Bootstrap guard rejects postgres:// URLs in sqlite-compiled binary
  with actionable error message
- Replace bytemuck with to_le_bytes/from_le_bytes in db_vector_store.rs
  and response_cache.rs (fixes silent data loss on PostgreSQL BYTEA)
- MemoryConfig::database_url field + ZEPH_DATABASE_URL vault key
- testcontainers integration tests (4 #[ignore] tests) for migrations,
  idempotency, CRUD, and FTS trigger verification
- Unit tests for all Dialect constants and FTS helpers

Tests: 7155/7155 passed
@github-actions github-actions bot added documentation Improvements or additions to documentation memory zeph-memory crate (SQLite) rust Rust code changes core zeph-core crate dependencies Dependency updates enhancement New feature or request size/XL Extra large PR (500+ lines) labels Mar 28, 2026
@bug-ops bug-ops enabled auto-merge (squash) March 28, 2026 23:05
@bug-ops bug-ops merged commit 6bb10ea into main Mar 28, 2026
25 checks passed
@bug-ops bug-ops deleted the feat/m28/db-abstraction-phase2 branch March 28, 2026 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core zeph-core crate dependencies Dependency updates documentation Improvements or additions to documentation enhancement New feature or request memory zeph-memory crate (SQLite) rust Rust code changes size/XL Extra large PR (500+ lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant